.zip mimetype
Posted: Thu Oct 30, 2003 7:43 pm
Ok, I have a script that uploads a file but before doing that it makes sure that the file is a .zip file by comparing the mimetype. I get the mimetype of the file using the code:
and then I run it through:
But heres the catch, it outputs the error message: "Upload failed. Please upload files only with the extension .zip. This file's MIME type was application/zip." If $filetype is coming out as application/zip then why is the if statement not true!?! I checked the spelling and it's spelled right, but it's not working.
Please help, I'm going crazy
.
Code: Select all
<?php
$filetype=$_FILES['userfile']['type'];
?>Code: Select all
<?php
if (!$error_message){
if ($filetype == "application/zip"){
$extension=".zip";
}
if ($filetype == "application/x-zip-compressed"){
$extension=".zip";
}
else{
$error_message="Upload failed. Please upload files only with the extension .zip. This file's MIME type was $filetype.";
}
//...
if ($error_message){
die ($error_message);
}
?>Please help, I'm going crazy