输入的accept属性无法识别application / json?

Jua*_*rer 11 html json

我有一个应用程序需要用户输入文件。它接受的文件类型之一是JSON。

在文件扩展名inputaccept被公认的精细大多数浏览器(Safari浏览器是主要的异常值),所以有时需要使用的MIME类型。对于JSON,扩展名可以正常工作,但是如果使用正确的MIME类型,则输入默认为“所有文件”作为过滤器。

Extension (.json): <br>
<input type="file" accept=".json">

<br><br>

MIME type: (application/json): <br>
<input type="file" accept="application/json">
Run Code Online (Sandbox Code Playgroud)

就我所知,这仅在JSON中发生。这是为什么?类型尚未被完全接受吗?是虫子吗?

编辑

经过测试:

                        | First | Second |
------------------------|-------|--------|
Windows 10/Chrome 61    |Success|  Fail  |
Windows 10/Firefox 56   |Success|Success |
OSX ElCapitan/Safari 9  | Fail  |Success |
Windows 10/Edge 40      |Success|  Fail  |
Run Code Online (Sandbox Code Playgroud)

看到它在Firefox上运行后,我开始认为这是Chrome上的错误。

小智 19

请试试这个标题:

accept="application/JSON"

它对我有用。