Jump to content


temporary folder (php)


10 replies to this topic

#1 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 06 February 2007 - 04:49 PM

The script i wrote is having trouble copying big (over 2mb) files from the temporary folder. Ive tried many different alternatives to uploads and none work. My hosting says that its not the server. So whats wrong?

Edited by Hip Hop Artist, 06 February 2007 - 05:42 PM.


#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 06 February 2007 - 06:53 PM

You'll need to check your php.ini settings. There is a setting called 'upload_max_filesize' and is default set to 2M (2MB). Look it up in your typical phpinfo() or use ini_get('upload_max_filesize').

Edited by Demonslay, 06 February 2007 - 06:55 PM.


#3 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 06 February 2007 - 06:55 PM

View PostDemonslay, on Feb 6 2007, 11:53 PM, said:

You'll need to check your php.ini settings. There is a setting something like 'max_upload' or something. Look it up in your typical phpinfo() or use ini_get().


where can i find the php.ini file?

#4 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 06 February 2007 - 06:58 PM

You have to ask your host about it because its a core file...

#5 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 06 February 2007 - 06:59 PM

i did that and he said that its my script.....i know the scripts not wrong thought the only error i get is a copy error or when i change it to the move_file function it a moving error.

#6 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 06 February 2007 - 07:00 PM

Then you'll have to show us the script, which I'm surprised wasn't the first thing you did.

Just double check that php.ini setting anyways, never hurts to check yourself by just running your typical phpinfo() and looking for 'upload_max_filesize'.

#7 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 06 February 2007 - 07:02 PM

ok will do but for now heres the script:

<?
session_start();
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("db_content") or die(mysql_error());
$name1 = $_POST['name'];
$comments1 = $_POST['comments'];
$small_des1 = $_POST['small_des'];
$genre = $_POST['genre'];
$tos = $_POST['tos'];
$user = $_SESSION['s_username'];
$num = 1;
$date = getdate();
$sub_date = $date['month']." ".$date['mday']." ".$date['year'];
srand ((double) microtime( )*1000000);
$random_number = rand( );

$name = htmlspecialchars($name1 , ENT_QUOTES);
$comments = htmlspecialchars($comments1 , ENT_QUOTES);
$small_des = htmlspecialchars($small_des1 , ENT_QUOTES);

$rand_name = $random_number."".$name.".mp3";
$rand_avatar = $random_number."".$name.".gif";
$file_link = "/portal/uploads/mp3_music/".$rand_name;
$avatar_link = "/portal/uploads/avatars/".$rand_avatar;

echo("<link rel='stylesheet' type='text/css' href='/main_style.css' />");
echo("<center>");

if($_SESSION['s_logged_n'] == 'true'){
$sql_check = mysql_query("SELECT * FROM `music` WHERE `name`='$name'");
$check = mysql_num_rows($sql_check);
if(($check > 0)){
echo("Name already taken. Please go back and rename.");
exit();
} else if ($name == "") {
echo("No name given. Please go back and give your music a name.");
exit();
} else if ($comments == "") {
echo("Please add a comment to your music.");
exit();
} else if ($small_des == "") {
echo("Please add a small description to your music.");
exit();
} else if ($tos == "") {
echo("Please tick our portal submission terms.");
exit();
} else {
$filename = basename($_FILES['uploadedfile']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
if ($ext == "mp3") {
if ($_FILES['uploadedfile']['size'] > 1024*1024*5) {
echo("File size is too big to upload.");
exit();
}
if ($_FILES['avatar']['type'] == "image/gif" && $_FILES['avatar']['size'] < 1024*20) {
copy ($_FILES['avatar']['tmp_name'], "/home/site/public_html/portal/uploads/avatar s/".$rand_avatar)
or die ("Could not upload image. Try again.");
} else {
echo("Error with image. Please use GIF only and check the file size is not over 20KB.");
unlink("uploads/avatars/".$rand_avatar);
exit();
}
list($width, $height) = getimagesize("uploads/avatars/".$rand_avatar)
;
if ($width > 50 || $width < 50 || $height > 50 || $height < 50) {
echo ("Avatar image is larger than 50px by 50px please go back and change this.");
unlink("uploads/avatars/".$rand_avatar);
exit();
}
copy ($_FILES['uploadedfile']['tmp_name'], "/home/site/public_html/portal/uploads/mp3_mu sic/".$rand_name)
or die ("Could not upload music. Try again.");
mysql_query("INSERT INTO `music` (`id`, `name`, `file_link`, `comments`, `avatar_link`, `user`, `small_des`, `genre`, `score_total`, `num_votes`, `sub_date`) VALUES ('', '$name', '$file_link', '$comments', '$avatar_link', '$user', '$small_des', '$genre', '2', '0', '$sub_date');");
$r = mysql_query("SELECT * FROM `music` WHERE `name` = '$name'");
$s = mysql_fetch_array($r);
$id = $s['id'];
mysql_select_db("db_login") or die(mysql_error());
$query = mysql_query("SELECT * FROM `users` WHERE `username` = '$user'");
$y = mysql_fetch_array($query);
$numb = $y['subs'];
$new_num = $numb + $num;
mysql_query("UPDATE `users` SET subs='$new_num' WHERE username='$user'");
echo("File uploaded successfully. Click here to view.");
} else {
echo "Wrong filetype! Please try again.";
exit();
}
}
} else {
header("Location: /user/login.php");
}

echo("</center>");
?>

#8 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 06 February 2007 - 07:09 PM

btw you were right upload_max_filesize is 2M thanks for the help!

Edited by Hip Hop Artist, 06 February 2007 - 07:09 PM.


#9 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 06 February 2007 - 07:15 PM

What error are you getting, is it killing the script and giving the die error from the copy() line? Or is the copy() function itself throwing an error?

All I see is a space in the filepath on this line.
copy ($_FILES['uploadedfile']['tmp_name'], "/home/site/public_html/portal/uploads/mp3_mu sic/".$rand_name)
or die ("Could not upload music. Try again.");

(By the way you know you can use code tags to better read code...)

#10 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 06 February 2007 - 08:23 PM

well the copy function is the thing giving me the error

#11 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 06 February 2007 - 08:49 PM

And what is this error? You can't just say 'I have this giving me an error' and expect me to know exactly what it is telling you and be able to tell what to do about it.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users