Jump to content

[SOLVED] Error uploading pictures with IE, works with FF


kickoutbettman

Recommended Posts

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;}

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.