6

这是我的上传输入,无论我尝试什么,它都会拒绝显示 Powerpoint PPS 文件。

它显示 PDF、PPT、PPTX、PPSX 但不显示 PPS

    <input type="file"
    accept="application/pdf,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/vnd.openxmlformats-officedocument.presentationml.presentation"
 name="upldInput"/>

所有浏览器的行为都是相同的,没有人显示 PPS 文件。

4

2 回答 2

3

我找不到有效的 MIME 类型。但是,以下方法确实有效:

<input type="file" accept="application/pdf,.pps" name="upldInput"/>

显然,您可以混合和匹配文件扩展名和 MIME 类型。在 Chrome 25 和 IE 10 (PC) 上,这提供了所需的行为,即仅显示匹配的 MIME 类型扩展名。

演示:http: //jsfiddle.net/GGFVv/

我也尝试过混合多个扩展和多种 MIME 类型,这似乎也有效。

<input type="file" 
    accept=".pps,
    .jpg,
    .txt,
    application/pdf,
    application/vnd.ms-powerpoint,
    application/vnd.openxmlformats-officedocument.presentationml.slideshow,
    application/vnd.openxmlformats-officedocument.presentationml.presentation" name="upldInput"/>

Demo: http://jsfiddle.net/GGFVv/2/

I should note that file extension filtering does not seem to work in Firefox 19. I imagine this is because of the differences between the behavior defined by the W3C and the WHATWG.

The original mention of accept (in 1995!) is somewhat vague:

Allow an ACCEPT attribute for INPUT tag, which is a list of media types or type patterns allowed for the input.

Firefox appears to default to "all files" when it finds a value it doesn't recognize, so this is somewhat user-friendly (though not ideal).

于 2013-04-01T23:18:46.960 回答
2

编辑:您是否尝试简单地添加:accept=".pps"

<input type="file"
   accept="application/pdf,
      application/vnd.ms-powerpoint,
      application/vnd.openxmlformats-officedocument.presentationml.slideshow,
      application/vnd.openxmlformats-officedocument.presentationml.presentation,
      .pps"
   name="upldInput"/>
于 2013-04-01T22:58:42.843 回答