Nordskjold Posted October 17, 2009 Share Posted October 17, 2009 I have a problem with upload images when the ending is .JPG capitalized.. I really don't know what causes it to crash but been testing it for some time and it's my retrictions that won't allow it in. Also I'm experiencing that it sometimes deny to upload pictures if the height or width of that image is above 2000. Here's the code: if(($_FILES[$Ufile]["type"] == "image/jpeg" || $_FILES[$Ufile]["type"] == "image/jpg" || $_FILES[$Ufile]["type"] == "image/pjpeg") && ($_FILES[$Ufile]["size"] < 2000000)) Thanks in front^^ Quote Link to comment https://forums.phpfreaks.com/topic/178022-solved-help-uploading-jpg/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 17, 2009 Share Posted October 17, 2009 For debugging, add the following code immediately after the first opening <?php tag in your form processing code and post what you get after you submit the form - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(E_ALL); echo "<pre>"; echo "POST:"; print_r($_POST); echo "FILES:"; print_r($_FILES); echo "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/178022-solved-help-uploading-jpg/#findComment-938634 Share on other sites More sharing options...
Dorky Posted October 17, 2009 Share Posted October 17, 2009 a bit of info handed to me on here the other day may help. strtolower( as well the 2000 my be irrelevant, if you are on an online host it may be the file size not image size but if the images are of the same source all 2000 size img will have relative file size. if you have the php gd libs you can simply recreate the image in the same px size and it will have a smaller file size. Quote Link to comment https://forums.phpfreaks.com/topic/178022-solved-help-uploading-jpg/#findComment-938646 Share on other sites More sharing options...
Nordskjold Posted October 20, 2009 Author Share Posted October 20, 2009 Thank you PFMaBiSmAd, for your input, but unfortunately the only output i get when trying is: POST:Array ( [upload] => Upload ) FILES:Array ( [file1] => Array ( [name] => DSC00127.JPG [type] => [tmp_name] => [error] => 1 => 0 ) ) Can't really figure out what i'd do with that.. Still can't upload .JPG i can upload an image as long as the ending is .jpg lowercase. Quote Link to comment https://forums.phpfreaks.com/topic/178022-solved-help-uploading-jpg/#findComment-940271 Share on other sites More sharing options...
PFMaBiSmAd Posted October 20, 2009 Share Posted October 20, 2009 For debugging... Can't really figure out what i'd do with that. Wouldn't something that shows there is an error have significance - [error] => 1 http://www.php.net/manual/en/features.file-upload.errors.php ALL CODE that is responsible for processing user supplied data must check for all possible errors and validate that data before blindly attempting to use that data. Put some error checking into your code so that at least when a file is uploaded that is larger than the upload_max_filesize setting that you output a meaningful user message. And while you are at it, when the size of the uploaded file exceeds the post_max_size setting, the $_FILES array is completely empty and you need to check for that condition as the first validation test - http://www.php.net/manual/en/ini.core.php#ini.post-max-size Quote Link to comment https://forums.phpfreaks.com/topic/178022-solved-help-uploading-jpg/#findComment-940424 Share on other sites More sharing options...
Dorky Posted October 20, 2009 Share Posted October 20, 2009 when the ending is .JPG capitalized i assumed this was an indication the problem null for images with .jpg Also I'm experiencing that it sometimes deny to upload pictures if the height or width of that image is above 2000. Here's the code: && ($_FILES[$Ufile]["size"] < 2000000)) strtolower($_FILES[$Ufile]["type"] ) Quote Link to comment https://forums.phpfreaks.com/topic/178022-solved-help-uploading-jpg/#findComment-940588 Share on other sites More sharing options...
Nordskjold Posted October 21, 2009 Author Share Posted October 21, 2009 Thank you all, made it all work, didn't realize so much error caring was needed, and Dorky thank you for the strtolower, it worked ^^ Quote Link to comment https://forums.phpfreaks.com/topic/178022-solved-help-uploading-jpg/#findComment-940989 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.