【问题标题】:Create filter on html file chooser dialog在 html 文件选择器对话框上创建过滤器
【发布时间】:2012-12-12 08:44:52
【问题描述】:

有没有办法在默认文件选择器对话框中只显示 .xxx 文件。 xxx 可能是未知的文件类型,例如 abc、efg 等。

我使用的是 html5,所以它可能对这种类型的东西有新的支持。

谢谢!

【问题讨论】:

    标签: html openfiledialog


    【解决方案1】:

    file 输入元素上的HTML 5 accept attribute 就是为此目的。例如:

    <input type="file" accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">
    

    【讨论】:

    • 谢谢老兄,正是我要找的
    【解决方案2】:

    对于其他到达这里的人,这些是一些非常方便的预定义集:

    <input type="file" accept="image/*"/>
    <input type="file" accept="video/*"/>
    <input type="file" accept="audio/*"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-01
      • 2015-11-29
      • 1970-01-01
      • 2015-03-31
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多