richrock Posted February 16, 2009 Share Posted February 16, 2009 Well, I managed to sort out the image uploads for my local server, and I can resize images based on some pre-defined criteria... Not a problem there - it's got a good process, and I'm usually resizing with about 80-90% quality, creating images around 7-300k. I've uploaded this to my online test server, and I cannot upload more than 2mb of images without getting a 500 Internal Server Error. Spent all morning trying to figure out why - here's what I've done: Tried ini_set() on the actual script. Nothing. Created a php.ini based on some tutorials - registers the changes using phpinfo, but again, cannot upload two images, or larger than 2mb. Copied an existing php.ini from a site I did where it is working allowing video uploads of 32mb. Doesn't work. Used unset() on most variables in the image processing script - this got me as far as managing to make images upload, again up to 2mb. Here's the php, which all it has to do is process a maximum of 3 images, resizing them into 3 sizes, and then copying the original into a hires backup folder. Not too hard huh? $img_number = 0; //echo "Img Num: ".$img_number."<br />"; if ($error == UPLOAD_ERR_OK) { // Little Old GD2 resize library $newname = $rec_num."-".$line_num.".jpg"; $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; move_uploaded_file($tmp_name,$path.$newname); foreach ($_FILES["pictures"]["error"] as $key => $error) { $th_width = '62'; $th_height = '93'; $re_width = '132'; $re_height = '198'; $mi_width = '320'; $mi_height = '480'; $lg_width = '892'; $lg_height = '1338'; //echo "TMP Name: ".$tmp_name."<br />"; //$name = $_FILES["pictures"]["name"][$key]; $path = AUCTION_PICTURES_PATH; //echo "PATH: ".$path."<br />"; // Process the file $filename = $newname; $thumb_path = $path."thumb_".$newname; $resize_path = $path."resize_".$newname; $middle_path = $path."middle_".$newname; $hires_path = $path."/hires/".$newname; list($width, $height) = getimagesize($path."thumb_".$newname); $image_p = imagecreatetruecolor($th_width, $th_height); $image = imagecreatefromjpeg($path.$newname); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $th_width, $th_height, $width, $height); imagejpeg($image_p, $path."thumb_".$newname, 90); unset($image_p,$image,$width,$height,$th_width,$th_height); copy($path.$newname,$resize_path); list($width, $height) = getimagesize($path."resize_".$newname); $image_p = imagecreatetruecolor($re_width, $re_height); $image = imagecreatefromjpeg($path.$newname); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $re_width, $re_height, $width, $height); imagejpeg($image_p, $path."resize_".$newname, 90); unset($image_p,$image,$width,$height,$re_height,$re_width); copy($path.$newname,$middle_path); list($width, $height) = getimagesize($path."middle_".$newname); $image_p = imagecreatetruecolor($mi_width, $mi_height); $image = imagecreatefromjpeg($path.$newname); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $mi_width, $mi_height, $width, $height); imagejpeg($image_p, $path."middle_".$newname, 80); unset($image_p,$image,$width,$height,$mi_height,$mi_width); list($width, $height) = getimagesize($path.$newname); copy($path.$newname,$hires_path); $image_p = imagecreatetruecolor($lg_width, $lg_height); $image = imagecreatefromjpeg($path.$newname); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $lg_width, $lg_height, $width, $height); imagejpeg($image_p, $path.$newname, 80); unset($image_p,$image,$width,$height,$lg_height,$lg_width); unset($tmp_name); ob_flush(); flush(); list($width, $height) = getimagesize($path.$newname); $image_p = imagecreatetruecolor($lg_width, $lg_height); $image = imagecreatefromjpeg($path.$newname); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $lg_width, $lg_height, $width, $height); imagejpeg($image_p, $path.$newname, 80); $img_number++; } // Endif } Quote Link to comment https://forums.phpfreaks.com/topic/145405-500-errors-based-on-uploads/ Share on other sites More sharing options...
.josh Posted February 16, 2009 Share Posted February 16, 2009 How about using ajax to submit files one at a time? (or onclick loop through, submitting them one at a time) Quote Link to comment https://forums.phpfreaks.com/topic/145405-500-errors-based-on-uploads/#findComment-763369 Share on other sites More sharing options...
richrock Posted February 16, 2009 Author Share Posted February 16, 2009 Sorry, wouldn't have a clue how to do these - onclick loopthrough sounds good tho. Where could I get more info about this? Quote Link to comment https://forums.phpfreaks.com/topic/145405-500-errors-based-on-uploads/#findComment-763455 Share on other sites More sharing options...
.josh Posted February 16, 2009 Share Posted February 16, 2009 google ajax file upload Quote Link to comment https://forums.phpfreaks.com/topic/145405-500-errors-based-on-uploads/#findComment-763477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.