kickoutbettman Posted September 10, 2009 Share Posted September 10, 2009 Hi all, I'm having an issue with IE vs Firefox. I have a little simple script to upload pictures. Works fine in FF but it failed with IE7. Here's a part of my code, but it looks like this line cause the error. Anybody can help me with this, let me know if you need any other info. Thanks if (!($_FILES['uploaded']['type'] =="image/jpeg" OR $_FILES['uploaded']['type']=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR/>"; exit;} Quote Link to comment https://forums.phpfreaks.com/topic/173782-solved-error-uploading-pictures-with-ie-works-with-ff/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 10, 2009 Share Posted September 10, 2009 When a test/comparison fails for user supplied data, echo out the actual value that is failing so that you know what it is. IE provides some different mime types than other browsers. Quote Link to comment https://forums.phpfreaks.com/topic/173782-solved-error-uploading-pictures-with-ie-works-with-ff/#findComment-916065 Share on other sites More sharing options...
kickoutbettman Posted September 10, 2009 Author Share Posted September 10, 2009 In fact it's an "image/pjpeg" Is there any different procedure to upload one of thoses ? Quote Link to comment https://forums.phpfreaks.com/topic/173782-solved-error-uploading-pictures-with-ie-works-with-ff/#findComment-916081 Share on other sites More sharing options...
Bricktop Posted September 10, 2009 Share Posted September 10, 2009 Hi kickoutbettman, That is the problem, Internet Explorer reads JPEG files differently to Firefox. Change your code to: if (!($_FILES['uploaded']['type'] =="image/jpeg" OR $_FILES['uploaded']['type'] =="image/pjpeg" OR $_FILES['uploaded']['type']=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR/>"; exit;} Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/173782-solved-error-uploading-pictures-with-ie-works-with-ff/#findComment-916085 Share on other sites More sharing options...
Stuie_b Posted September 10, 2009 Share Posted September 10, 2009 The problem lies in the browser, because php doesn't handle file mime types, the mime is browser specific, one solution to this problem is to manually check the filename for the correct extensions, <?php if (!eregi(".jpg",$_FILES['uploaded']['filename']) OR !eregi(".gif",$_FILES['uploaded']['filename'])){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR/>"; exit;} ?> Stuie Quote Link to comment https://forums.phpfreaks.com/topic/173782-solved-error-uploading-pictures-with-ie-works-with-ff/#findComment-916090 Share on other sites More sharing options...
keldorn Posted September 10, 2009 Share Posted September 10, 2009 Google has results for image/pjpeg problems. Gotta give your thanks to the geniuses at Microsoft. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/173782-solved-error-uploading-pictures-with-ie-works-with-ff/#findComment-916092 Share on other sites More sharing options...
kickoutbettman Posted September 10, 2009 Author Share Posted September 10, 2009 Works perfectly, thanks all for your help. Quote Link to comment https://forums.phpfreaks.com/topic/173782-solved-error-uploading-pictures-with-ie-works-with-ff/#findComment-916098 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.