Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove "All Files" option from uploader [duplicate]

I am using

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

To upload only selective files i am using "accept". So dialog box contains my selected types of files extension. But there is an option of "All Files" which i do not want there.

How can I remove this option?

enter image description here

like image 407
rao Avatar asked Sep 16 '14 07:09

rao


1 Answers

The best you can do (natively) 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
    {...}
}

Sample code : ( 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

like image 137
Royi Namir Avatar answered Sep 21 '22 14:09

Royi Namir