从上传程序中删除"所有文件"选项

rao*_*rao 7 html javascript jquery

我在用

< input type="file" >
上传文件.

要仅上传选择性文件,我使用"接受".因此,对话框包含我选择的文件扩展名类型.但是有一个"所有文件"的选项,我不想要那里.

如何删除此选项?

在此输入图像描述

Roy*_*mir 2

您可以(本地)做的最好的事情就是检查选择了哪个文件:

<input   id="uploadFile" type="file"  onchange="FileSelected(this)"  />
Run Code Online (Sandbox Code Playgroud)

脚本 :

function FileSelected(sender)
{
    if (check(sender.value)) //check is you function to check extension 
    {...}
    else
    {...}
}
Run Code Online (Sandbox Code Playgroud)

示例代码:(仅检查jpg)
http://jsbin.com/sibose/2/edit

编辑

在铬合金中。ie10你可以这样做:

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

与 FF :

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

演示: http: //jsbin.com/jihoku/2/edit