HTML 输入标签中用于显示 .p7m 文件的 accept 属性的正确值是多少?

What is the correct value for the accept attribute in HTML input tag to show .p7m files?

我有以下问题,我想创建一个 HTML 输入字段,用户可以在其中上传 .p7m 文件,如果他点击它,他应该只能看到该类型的文件,但是它不能正常工作。 要更改显示的文件,我通常会更改 "accept" 属性,如下例所示。

<input class="uploadFile" name="file" type="file" id="file" placeholder="Your P7M..." accept="application/pkcs7-mime" >

令我困扰的是,我在 Windows 10 上的 Firefox 60.4.0esr(64 位)中选择的值没有显示正确的文件:

Google Chrome 在同一台机器上也显示 .p7m 文件。

浏览器将自己的数据和 OS 数据组合用于 MIME 类型 <-> 文件扩展名映射。

Chrome 显然有 hardcoded mappings for "application/pkcs7-mime", which are used when the OS doesn't provide info on the MIME type.

Firefox 没有,所以我认为在您的情况下它显示了 OS 中配置的扩展。 (如果有人好奇,这里是您系统上的 entry point, the hardcoded values and the code that queries the OS on Windows.) Check what's in HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/pkcs7-mime

我认为您无法通过网页控制它。