Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML file input accept only .zip files (not .exe)

Tags:

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.

like image 469
2778 Avatar asked Jul 18 '14 19:07

2778


People also ask

How do I allow HTML to upload a file?

HTML allows you to add the file upload functionality to your website by adding a file upload button to your webpage with the help of the <input> tag. The <input type=”file”> defines a file-select field and a “Browse“ button for file uploads.


1 Answers

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">
like image 163
Waruna Manjula Avatar answered Oct 11 '22 17:10

Waruna Manjula