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? Quote Link to comment 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.) Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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)) { Quote Link to comment 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.