garydt Posted August 14, 2007 Share Posted August 14, 2007 I've a script that lets users upload jpeg images and then the script resizes them. I've tried uploading an image sized 1.95MB and 2150 pixels wide, it uploads fine. However, when i tried uploading an image sized 1.24MB and 2575 pixels wide i got server error whch i find weird. Anyone know why? My php.ini- upload_max_filesize: 20M max_execution_time: 300 memory_limit: 40M post_max_size: 16M SMTP: localhost Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/ Share on other sites More sharing options...
MadTechie Posted August 14, 2007 Share Posted August 14, 2007 maybe the reading the error would help.. or atleast let us know what the error is.. either that or i could guess out of memory or a timeout.. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323351 Share on other sites More sharing options...
garydt Posted August 14, 2007 Author Share Posted August 14, 2007 the error is server error 500. How high should i go with the memory_limit and the max_execution_time? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323370 Share on other sites More sharing options...
MadTechie Posted August 14, 2007 Share Posted August 14, 2007 try a higher amount i can really say.. or a little larger image until it fails. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323416 Share on other sites More sharing options...
garydt Posted August 14, 2007 Author Share Posted August 14, 2007 I've changed the php.ini to upload_max_filesize: 20M max_execution_time: 300 memory_limit: 80M post_max_size: 16M SMTP: localhost tried uploading a 1.24mb image, 2550pixels wide and got- Error 500 - Internal server error An internal server error has occured! Please try again later. Surely, the settings in the php.ini must b high enough?? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323499 Share on other sites More sharing options...
HuggieBear Posted August 14, 2007 Share Posted August 14, 2007 Does the script upload and resize without outputting anything to the browser? If it does then I'd be willing to bet that it's not the uploading part that's the problem, but more the resizing part. Try to echo something to the screen post upload but pre resize and see if it works for both. Are you using the GD library for resizing? Go here to get an idea of how to calculate the memory usage required... Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323503 Share on other sites More sharing options...
garydt Posted August 14, 2007 Author Share Posted August 14, 2007 Thanks, Huggie. Yes, it must be the resize script as i tried echoing something to the screen before the resizing and it came up. No, I'm not using the GD library for resizing.. Here's my resizing 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]; //max height: 100px; max width: 100px 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 } } It does work sometimes. What's wrong with it? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323528 Share on other sites More sharing options...
garydt Posted August 14, 2007 Author Share Posted August 14, 2007 can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323580 Share on other sites More sharing options...
jishosan Posted August 14, 2007 Share Posted August 14, 2007 Perhaps a strange question, but your comments note that you want a maximum thumbnail size of 100x100. However, your code seems to set the longest side to 140px. Was that just an intentional feature change? Looking at the information you posted, you have PHP memory_limit set to 40M, which should be plenty. Are the images coming from two different sources? Can you add some echo statements to echo your assigned values as the script runs? If one of your values resolves to 0, you might be experiencing a divide by zero error. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323640 Share on other sites More sharing options...
garydt Posted August 14, 2007 Author Share Posted August 14, 2007 Thanks. I forgot to change comments to 140px The images come from what users upload. I've echoed the assigned values such as $thumb_width and $thumb_height, no value resolves to 0. This is really annoying as it works on smaller images. What can i do now? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323689 Share on other sites More sharing options...
jishosan Posted August 14, 2007 Share Posted August 14, 2007 Can you echo out the $im_divice variable? Or better yet, echo ALL your variables before the $thumb= statement and post the output. Also, have you checked the site logs for any expanded error information? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323792 Share on other sites More sharing options...
garydt Posted August 14, 2007 Author Share Posted August 14, 2007 Here are all the echoed values- im_width3072 Notice: Use of undefined constant im_height - assumed 'im_height' in C:\Program Files\xampp\htdocs\epeople\uploadform.php on line 104 im_height2304 Notice: Use of undefined constant im_flag - assumed 'im_flag' in C:\Program Files\xampp\htdocs\epeople\uploadform.php on line 105 im_flag2 Notice: Use of undefined constant im_divice - assumed 'im_divice' in C:\Program Files\xampp\htdocs\epeople\uploadform.php on line 109 im_divice21.9428571429 Notice: Use of undefined constant thumb_width - assumed 'thumb_width' in C:\Program Files\xampp\htdocs\epeople\uploadform.php on line 116 thumb_width140 Notice: Use of undefined constant thumb_height - assumed 'thumb_height' in C:\Program Files\xampp\htdocs\epeople\uploadform.php on line 117 thumb_height105 How do i check the site logs for any expanded error information? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323875 Share on other sites More sharing options...
garydt Posted August 14, 2007 Author Share Posted August 14, 2007 It resizes big images fine when i try on my local server but on the remote server i get internal server error 500 Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323888 Share on other sites More sharing options...
jishosan Posted August 14, 2007 Share Posted August 14, 2007 Are you able to view or modify the php.ini memory information on the remote server? If you're using shared hosting, you might be facing an issue with their memory limits. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-323962 Share on other sites More sharing options...
garydt Posted August 14, 2007 Author Share Posted August 14, 2007 yes i can view/modiy php.ini. memory_limit is 40M. shall i increase it? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324017 Share on other sites More sharing options...
jishosan Posted August 14, 2007 Share Posted August 14, 2007 Yes, increase it to 80 and see if you get the same error. Probably 60M would be enough, but 80M is a safe number. Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324024 Share on other sites More sharing options...
HuggieBear Posted August 15, 2007 Share Posted August 15, 2007 From what I can see you are using the GD library. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324425 Share on other sites More sharing options...
garydt Posted August 15, 2007 Author Share Posted August 15, 2007 Huggie, yes, my mistake. i've increased the Memory_limit to 140M. When I try uploading an image i see the browser working for 40-50 seconds and then it brings up the page which says the image isn't a jpeg but i know it is. When i try another jpeg it saves it to the server but i get the server error when it tries to resize it. I'm totally confused! Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324501 Share on other sites More sharing options...
MadTechie Posted August 15, 2007 Share Posted August 15, 2007 what errors? i assume its just timieng out also the "not image", try save it to your desktop and open it in wordpad (you may see an error at the top) Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324530 Share on other sites More sharing options...
garydt Posted August 15, 2007 Author Share Posted August 15, 2007 i opened the image in word (i dont have wordpad), i saw no error. I tried uploading a 442k jpeg, 3500pixels wide. It saved to the server but when it came to resizing the image i got server error 500. This is my php.ini file now- upload_max_filesize: 20M max_execution_time: 300 memory_limit: 300M post_max_size: 16M SMTP: localhost extension=php_gd2.dll Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324554 Share on other sites More sharing options...
garydt Posted August 15, 2007 Author Share Posted August 15, 2007 Can anyone help please? Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324618 Share on other sites More sharing options...
MadTechie Posted August 15, 2007 Share Posted August 15, 2007 shot in the dark try max_execution_time: 0 thats zero also if(memory_get_usage() > 20000000) die("Out of memory"); might helps with debugging Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324619 Share on other sites More sharing options...
garydt Posted August 15, 2007 Author Share Posted August 15, 2007 I tried both things and i still get server error 500. This is so frustrating! Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324767 Share on other sites More sharing options...
MadTechie Posted August 15, 2007 Share Posted August 15, 2007 if i have time will try on my server when i get home Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324813 Share on other sites More sharing options...
garydt Posted August 15, 2007 Author Share Posted August 15, 2007 Thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/64820-weird-problem-with-uploading-big-images/#findComment-324822 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.