29

using this for the accept field in my file input:

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

Result:

  • Internet Explorer: Only shows .zip. Yay.
  • FireFox: shows all files, but I can change dropdown to only show .zip. Can I change .zip to be the default view somehow?
  • Chrome: shows .zip and .exe. How do I exclude .exe?

I know chrome is technically right, but I'm trying to be user friendly here.

Soviut
  • 88,194
  • 49
  • 192
  • 260
2778
  • 814
  • 1
  • 11
  • 32

2 Answers2

46

try

<!-- (IE 10+, Edge, Chrome, Firefox 42+) -->
<input type="file" accept=".zip,.rar,.7zip" />

<input type="file" accept="zip,application/octet-stream,application/zip,application/x-zip,application/x-zip-compressed">
Waruna Manjula
  • 3,067
  • 1
  • 34
  • 33
9

application/octet-stream is the "catch-all" bucket. It's the default mime-type if the filename has no extension to help determine it. It's also the source of your EXE representation in Chrome, I'm guessing.

Limit file format when using <input type="file">?

You can also try reducing it with the "accept" attribute on the INPUT/File. That link above also has a link to a JSFiddle page you can play and test with.

Community
  • 1
  • 1
Jason
  • 3,020
  • 2
  • 24
  • 23