Upload Script - Wont Upload Big Files
I recently edited my image upload script because it was poorly written the first time, and now it wont upload files larger then a thumb nail. I am not getting any errors or anything. I changed my error_reporting to E_ALL | E_STRICT and only get undefined variable warning.
i have 200+ lines of code in this script, so here is just the main upload part:
PHP Code:
switch($newalbumstat) {
case "true":
#IS A NEW ALBUM, GET ALBUM ID, INSERT INTO DB, THEN UPLOAD
$sql = "SELECT `album_id` FROM `picture_albums` WHERE `name`='$newalbum' AND member_id='$memid' LIMIT 1";
$query = mysql_query($sql);
$a = mysql_fetch_array($query);
$albumid = $a['album_id'];
#ADD IMAGE TO DATABASE
$fullurl = "http://pics.rapidfriends.com/$memid/$newpicname";
$uploadurl = "pics/$memid/$newpicname";
$caption = $_POST['caption'];
$sql = "INSERT INTO `pictures` SET member_id='$memid', caption='$caption', url='$fullurl', album='$albumid'";
$query = mysql_query($sql);
$result = move_uploaded_file($_FILES["image"]["tmp_name"], $uploadurl);
func_makethumb_avatar_upload($uploadurl,400,$ext);
$res=chmod($uploadurl,0755);
break;
case "false":
#NOT A NEW AlBUM
//$albumid = $_POST['album'];
$fullurl = "http://pics.rapidfriends.com/$memid/$newpicname";
$uploadurl = "pics/$memid/$newpicname";
$caption = $_POST['caption'];
$sql = "INSERT INTO `pictures` SET member_id='$memid', caption='$caption', url='$fullurl', album='$albumid', location='$uploadurl'";
$query = mysql_query($sql);
$result = move_uploaded_file($_FILES["image"]["tmp_name"], $uploadurl);
func_makethumb_avatar_upload($uploadurl,400,$ext);
$res=chmod($uploadurl,0755);
break;
}
Re: Upload Script - Wont Upload Big Files
It's possible that if uploading a large file takes too long, your script or the web server is hitting a timeout. The default max execution time on php is 30 seconds, so if it's failing quicker than that you can ignore the max_execution_time directive.
You'll also need to check what your timeout is set to on your webserver; apache and IIS both default to 300 seconds according to the PHP page.
Hope this helps.
Re: Upload Script - Wont Upload Big Files
Maximum execution time exceeded will produce a fatal error. Have you checked the error code for the uploaded file $_FILES['filename']['error'].
You also need to check the upload_max_filesize directive in php.ini. If your upload size is bigger than this, it will fail.
And WHEN are you going to learn to escape variables that go into sql? :mad:
Re: Upload Script - Wont Upload Big Files
escape meaning using / / ?
field=/"test"/?
Re: Upload Script - Wont Upload Big Files
No, a backslash. mysql_escape_string()
Re: Upload Script - Wont Upload Big Files
I told you it would be easier to use MySQLi or PDO. :p