Mime type for zip file in Google Chrome

I discovered a weird issue in zip file's mime type when I worked on a Symfony application.

According to w3school, the mime type for zip file is application/zip . This is what I believe, too.

But when I upload a zip file in my Symfony app with IE, the mime type of that zip file is application/x-zip-compressed . When I upload a zip file in Firefox, the mime type of that zip file is application/octet-stream .

None of them is application/zip as I would like to believe.

The weirdest behavior of all, is Google Chrome. When I upload a zip file in Google Chrome, I can't determine the correct mime type for it. Although I am pretty sure that it's not

application/zip   
application/x-zip
application/octet-stream
application/x-zip-compressed

The mime type for zip file in Google Chrome is an empty string, as I found out by dumping out the sfValidatorFile object returned. Note the sfValidatorFile.type is "" for zip file.

But the sfValidatorFile.type object returned for a jpeg file is jpeg .

Seems to me like there is a bug in either Symfony or Google Chrome

Futher info: It seems that Gmail interprets zip file's mime type as application/zip in Google Chrome. This is the correct behavior. Seems to confirm that it's Symfony's bug.


As of now, MIME type of a zip file is application/octet-stream in Google Chrome. :)


This is Google Chrome's bug not Symfony. I have the same problem with Google Chrome's ZIP mime.

I have my own application written in php.

When you write echo $_FILES['yournameattr']['type']; it returns empty string when you upload a zip file but when you upload a gif or jpeg file it returns image/jpeg or image/gif.

I have Google Chrome version 3.0.195.6 (beta).

Though if you need fast solution, you can use preg_match to check the file's extension (zip or not).

if (preg_match('/(.*).zip/',$_FILES['yournameattr']['name'])) {echo 'This is zip.';}

Seems to me like there is a bug in Symfony.

A ticket has been opened at here.

链接地址: http://www.djcxy.com/p/47022.html

上一篇: zip mime类型,何时选择哪一个

下一篇: Mime键入Google Chrome中的zip文件