garydt Posted August 13, 2007 Share Posted August 13, 2007 When I try to upload an image that is bigger than 2000 pixels wide i get server error 500. It does save the image on to the server. The error comes when it tries to resize the image. Here's the resize script- function resizeimage($name){ $filename = './uploads/'.$name; if(file_exists($filename)) { $image = imagecreatefromjpeg($filename); //unresized image $im_info = getimagesize($filename); //unresized image $im_width = $im_info[0]; $im_height = $im_info[1]; $im_flag = $im_info[2]; if($im_width >= $im_height) { $im_divice = $im_width / 140; }else { $im_divice = $im_height / 140; } $thumb_width = $im_width / $im_divice; $thumb_height = $im_height / $im_divice; //create empty image $thumb = imagecreatetruecolor($thumb_width, $thumb_height); //resize image imagecopyresampled($thumb, $image, 0, 0, 0, 0, $thumb_width, $thumb_height, $im_width, $im_height); if(imagejpeg($thumb, "thumbnails/".$name, 80)) { //image-resource, filename, quality return 1; } imagedestroy($thumb); //destroy temporary image-resource imagedestroy($image); //destroy temporary image-resource } } Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/ Share on other sites More sharing options...
frost Posted August 13, 2007 Share Posted August 13, 2007 The script is probably taking to long, can you increase your max_execution_time? Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-322650 Share on other sites More sharing options...
garydt Posted August 13, 2007 Author Share Posted August 13, 2007 Thanks I increased the max_execution_time to 60 and now i get- Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 10000 bytes) in /homepages/3/d209077294/htdocs/uploadform.php on line 95 Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-322772 Share on other sites More sharing options...
corillo181 Posted August 13, 2007 Share Posted August 13, 2007 this means that you are trying to upload a file size bigger than what you have set up in your php.ini file. so you just have to keep increasing the MAX_FILE_SIZE until you reach a reasonable upload size that you think is good for you. Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-322787 Share on other sites More sharing options...
garydt Posted August 13, 2007 Author Share Posted August 13, 2007 Thanks. I've put- <input type="hidden" name="MAX_FILE_SIZE" value="2000000000"> Tried uploading an image sized 1.95MB and 2150 pixels wide but when i tried uploading an image sized 1.24MB and 2575 pixels wide i got server error. That doesn't makes sense does it? Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-322861 Share on other sites More sharing options...
rawky1976 Posted August 13, 2007 Share Posted August 13, 2007 I think there's a max_file_size in php.ini as well as in your webpage! Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-322864 Share on other sites More sharing options...
garydt Posted August 13, 2007 Author Share Posted August 13, 2007 in the php.ini file i've got- upload_max_filesize: 20M is that the same thing? Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-322877 Share on other sites More sharing options...
rawky1976 Posted August 13, 2007 Share Posted August 13, 2007 I've got: - ;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ;upload_tmp_dir = ; Maximum allowed size for uploaded files. upload_max_filesize = 2M ...that's all I know about it sorry mate, I just read somewhere last time I was doing this that there was a similar entry in php.in. I was uploading docs not pics in a searchable knowledgebase type app. Got all my answers from this site though so keep on at 'em!! They're good! Mark Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-322891 Share on other sites More sharing options...
garydt Posted August 13, 2007 Author Share Posted August 13, 2007 Thanks. Tried uploading an image sized 1.95MB and 2150 pixels wide but when i tried uploading an image sized 1.24MB and 2575 pixels wide i got server error. Anyone know why this happens? Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-322923 Share on other sites More sharing options...
frost Posted August 14, 2007 Share Posted August 14, 2007 Have you restarted apache since changing the ini? Quote Link to comment https://forums.phpfreaks.com/topic/64699-upload-problem/#findComment-323572 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.