Graviton
Graviton

Reputation: 83306

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.

Upvotes: 18

Views: 61549

Answers (4)

hsu1943
hsu1943

Reputation: 21

file.type in javascript

os brower type
windows 11 chrome application/x-zip-compressed
windows 11 firefox application/x-zip-compressed
windows 11 edge application/x-zip-compressed
mac chrome application/zip
mac firefox application/zip
mac safari application/zip

Upvotes: 2

Celmaun
Celmaun

Reputation: 24762

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

Upvotes: 26

DedicatedChop
DedicatedChop

Reputation:

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.';}

Upvotes: 5

Graviton
Graviton

Reputation: 83306

Seems to me like there is a bug in Symfony.

A ticket has been opened at here.

Upvotes: 0

Related Questions