7

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

rao
  • 223
  • 2
  • 7
  • 17
  • I don't think this can be done. Certainly, not reliably, since it would depend on how the browser has chosen to implement this particular functionality. – ne1410s Sep 16 '14 at 07:17

1 Answers1

2

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

Community
  • 1
  • 1
Royi Namir
  • 144,742
  • 138
  • 468
  • 792