【问题标题】:Accept=".xls" not working in firefox and ie in HTMLAccept=".xls" 在 Firefox 和 HTML 中不起作用
【发布时间】:2014-11-14 18:34:37
【问题描述】:

我想打开文件参考窗口来上传 .xls 文件。所以我尝试通过在 accept 属性中设置“.xls”来过滤文件。

<input type="file" id="myFile" size="50" accept=".xls">

在 GoogleChrome 中过滤良好。

但在 Firefox 和 Ie 中,它没有过滤。

【问题讨论】:

    标签: html google-chrome internet-explorer firefox


    【解决方案1】:
    <input type="file" id="myFile" size="50" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" >
    

    设置 mimeType 就可以了

    【讨论】:

    • 在 FireFox 中,所有文件 (.) 和 Microsoft Excel(97-2003) 工作表 (.xls) 都列在组合框中。但是,默认情况下所有文件(.*)值被选中。我需要默认选择 Microsoft Excel(97-2003) WorkSheet (*.xls)。
    • 我认为你没有修复它,我在 BugZilla (bugzilla.mozilla.org/show_bug.cgi?id=826176) 上找到了文档,对于 mozilla 开发人员来说,你可以看到所有文件是正确的(.)
    • 从技术上讲,答案中的 accept 属性值同时指定了 .xls 和 .xlsx 文件,这可能比仅 .xls 更好,但问题要求使用 .xls(这是可以想象的)在某些情况下,可以接受 .xls 但不能接受 .xlsx)。要仅指定 .xls,您可以使用 accept="application/vnd.ms-excel"。
    猜你喜欢
    • 1970-01-01
    • 2013-04-23
    • 2015-09-19
    • 1970-01-01
    • 1970-01-01
    • 2014-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多