cant upload with internet explorer

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

cant upload with internet explorer

Post by pleigh »

hi, i have this code

Code: Select all

if (!($_FILES['uploaded']['type'] == "application/zip")) {
	echo "<font color='red'>You may only upload ZIP files.</font><br>";
}
in firefox, its running ok, but in internet exporer it doesn't. maybe you can help me with this. by the way, the upload will only honor .zip file extension.

thank you in advance
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

echo $_FILES['uploaded']['type'];
What does it say?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

firefox, i got this --> application/zip
ie, i got nothing.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

IE is not providing a mime type. You'll need to verify it is a zip server side.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Never assume what is in the "type" field of uploads as fact, as this has evidenced. You need to check the file's type yourself, always, unless you know exactly what you're doing.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

could you show me an example on how to fix this??i really dont know. :oops:
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

remove if (!($_FILES['uploaded']['type'] == "application/zip")) block and

Code: Select all

$za = new ZipArchive();

if(! $za->open($_FILES['uploaded']['tmp_name']))
  echo "<font color='red'>You may only upload ZIP files.</font><br>";
}
Post Reply