not recognizing the ZIP mime-type (application/zip)
itaine - April 25, 2009 - 12:32
| Project: | MimeDetect |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
When I set the 'permitted upload file extensions' to: zip rar
I'm getting the following when uploading a zip file:
"The selected file template.zip could not be uploaded. The file contents (application/x-zip) do not match its extension (zip)."

#1
Sounds like mimedetect isn't working properly to identify the file type. Have you set up the "file" command at admin/settings/mimedetect? It would probably help identify the problem if you could upload the file to drupal.org or if it's a large file, make it available for download elsewhere.
#2
thx for the quick response! Let me look into the mimedetect settings first and report back shortly.
when I go there I get the following
"The MimeDetect module is using PHP's fileinfo extension to detect MIME types. There are no settings for the extension. "
I unzipped the archive and rezipped it myself to make sure it actually a zip file. I will attach it though. Checked to make sure the php_fileinfo extension is active and it is. Mind you I'm of course testing on a wamp setup not sure if it requires to be on a UNIX server to work.
#3
#4
ok I've narrowed it down. Everything works as it should. It appears there is just a problem with the application/zip mime-type. I will update the title of this issue to reflect that.
#5
#6
yeah i think the magic library we ship is kind of limited. i'm not sure how to write a signature for it for zip files. might be better to use the system's if available. there's an issue for making the mime file customizable.
#7
when you say the system's are you referring to the upload module?
#8
It appears that fileinfo and file relies on a magic file. If this file is not current, this module will not work.
From the command line type "file filename" and it should something other than zip.
#9
This patch does two things: 1) Updates our magic file so that it returns "application/zip" instead of "application/x-zip" so that it matches file_get_mimetype() and 2) Makes mimedetect actually use the magic file. Right now it looks like we're shipping mimedetect with a magic file, but not actually using it anywhere.
#10
Definitely a bug but technically we are using it with the PHP mimedetech extension, just not the file command...
#11
Ah, right I hadn't seen that reference. It'd definitely be handy to use the same magic file in both places.
#12
minor tweak. committed to HEAD, D6 and D5.
#13
Works great, thanks drewish.
#14
Automatically closed -- issue fixed for 2 weeks with no activity.