bluedaniel Posted July 7, 2009 Share Posted July 7, 2009 This is an picture upload script that works in Firefox but not IE. Im only uploading a part of the script that I think is the culprit, if you need to see more I will oblige The error in IE is "Im sorry you can only upload a JPG which is under 1MB in size" which is outputted at the end of the script. <?php if (isset($_POST['upload'])) { if (isset($_FILES['uploaded_pic'])) { $id = $_POST['recipeID']; $filename = basename($_FILES['uploaded_pic']['tmp_name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($_FILES["uploaded_pic"]["type"] == "image/jpeg") && ($_FILES["uploaded_pic"]["size"] < 1000000)) { //Code not uploaded } else { $message = "Im sorry you can only upload a JPG which is under 1MB in size."; } } } ?> any ideas? Link to comment https://forums.phpfreaks.com/topic/165111-solved-yet-another-script-that-works-in-firefox-and-not-ie/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 7, 2009 Share Posted July 7, 2009 When a comparison fails, examine what the actual value is that failed. Echo out $_FILES["uploaded_pic"]["type"] to find what IE puts in it for the file type (different browsers send different mime types for the same file.) Link to comment https://forums.phpfreaks.com/topic/165111-solved-yet-another-script-that-works-in-firefox-and-not-ie/#findComment-870638 Share on other sites More sharing options...
bluedaniel Posted July 7, 2009 Author Share Posted July 7, 2009 oh man how much easier would our lives be with one browser!!! your right IE is image/pjpeg while Firefox image/jpeg, and one does not satisfy both browsers, how should my code look then? Link to comment https://forums.phpfreaks.com/topic/165111-solved-yet-another-script-that-works-in-firefox-and-not-ie/#findComment-870641 Share on other sites More sharing options...
PFMaBiSmAd Posted July 7, 2009 Share Posted July 7, 2009 The best way is to create an array of acceptable values and use in_array to test if a value is in that array. Link to comment https://forums.phpfreaks.com/topic/165111-solved-yet-another-script-that-works-in-firefox-and-not-ie/#findComment-870644 Share on other sites More sharing options...
bluedaniel Posted July 7, 2009 Author Share Posted July 7, 2009 excellent! Thank you so much. Working (and now universal!) code: $filetype = $_FILES["uploaded_pic"]["type"]; $acceptablefiletypes = array("image/pjpeg", "image/jpeg", "image/jpg"); if (in_array($filetype, $acceptablefiletypes) && ($_FILES["uploaded_pic"]["size"] < 1000000)) { Link to comment https://forums.phpfreaks.com/topic/165111-solved-yet-another-script-that-works-in-firefox-and-not-ie/#findComment-870647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.