Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.