Page 1 of 1

[SOLVED] mime type isn't right somehow

Posted: Mon Jan 15, 2007 7:02 am
by ryuuka
i got this site that needs to upload files and it only needs accept
zip files this is where the weird part comes in

i echo'ed everything and it says everything is a zip (even pdf's and psd files) file when i do this:

Code: Select all

$type = $_FILES['userfile']['type'];

if ($type = 'application/x-zip-compressed'){ 

//stuff

}
else
{
echo "this file is nozip file <br>";
echo "new upload";
}
and when i do this it does everything correct, it even gives the correct filetype

Code: Select all

$type = $_FILES['userfile']['type'];

if ($type != 'application/x-zip-compressed'){ 

//stuff

}
else
{
echo "this file is a  zip file <br>";
echo "new upload";
}
really weird

ps: please don't start about the safety and correctness of the $_files
variable. it serves my purpose well enough and my users are a bunch of ignorants :)
and no one from outside can get into this server

Posted: Mon Jan 15, 2007 7:22 am
by ryuuka
NM
i already solved it

Code: Select all

if ($type != 'application/x-zip-compressed')
{
echo "het bestand is geen zip file <br>";
echo "probeer een ander bestand te uploaden";
} 
else
{
//stuff
}
i have no idea why this works and the other thing doesn't
but frankly i don't give a damn as long as it works

Posted: Mon Jan 15, 2007 9:49 am
by feyd
Zip files can come in several content-types. Type information fed to you from the browser is absolutely unreliable 100% of the time. Check the file data itself.

mime_content_type() may be of use.