to download files. To download only custom files, I use "accep...">

Remove the "All Files" option from the bootloader

I use

  <input type = "file"> 
to download files.

To download only custom files, I use "accept". Therefore, the dialog box contains my selected types of file extensions. But there is an option "All files", which I do not want there.

How to remove this option?

enter image description here

+6
source share
1 answer

The best you can do (initially) is to check which file was selected:

<input id="uploadFile" type="file" onchange="FileSelected(this)" /> 

Script:

 function FileSelected(sender) { if (check(sender.value)) //check is you function to check extension {...} else {...} } 

Code example: (check only jpg)
http://jsbin.com/sibose/2/edit

Edit

in chrome. ie10 you can do:

 <!-- (IE 10+, Chrome) --> <input type="file" accept=".xls,.xlsx"> 

With FF:

 <!-- (IE 10+, Chrome, Firefox) --> <input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel" /> 

demo : http://jsbin.com/jihoku/2/edit

+2
source

Source: https://habr.com/ru/post/975342/


All Articles