所以我有一个标准的<input type="file" accept="..."/>
其中accept,是不同MIME类型的大列表。 我已经验证了服务器后端上的文件类型,但我想确定我没有筛选出客户端UI上的有效文件。我意识到旧版浏览器根本不会过滤文件,这很好。我担心现代浏览器可能无法识别MIME类型并过滤出实际有效的文件。接受属性中的值是否需要计算机知道MIME类型?
所以我的问题基本上是'accept'属性有多可靠?例如,如果未安装Microsoft Office,浏览器是否会识别.docx mime类型?此外,某些文件类型有许多不同的可能的MIME类型与它们相关联,如果我只列出其中一种MIME类型,它是否重要?
我不明白为什么规范最初使用MIME类型,它会明显更简单,我猜如果他们有第一次使用扩展(如铬接受)更可靠。
对于我目前用默剧的完整列表:
application/msword,
application/vnd.openxmlformats-officedocument.wordprocessingml.document,
application/rtf,
application/msexcel,
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
application/vnd.openxmlformats-officedocument.spreadsheetml.template,
application/vnd.ms-excel.template.macroEnabled.12,
application/vnd.ms-excel.sheet.macroEnabled.12,
text/csv,
application/mspowerpoint,
application/vnd.openxmlformats-officedocument.presentationml.presentation,
application/vnd.ms-powerpoint.presentation.macroEnabled.12,
application/vnd.ms-powerpoint,
application/vnd.openxmlformats-officedocument.presentationml.template,
application/vnd.openxmlformats-officedocument.presentationml.slideshow,
application/pdf,
image/jpg,
image/jpeg,
image/png,
image/bmp,
image/gif,
text/plain,
message/rfc822,
application/vnd.oasis.opendocument.text,
application/vnd.oasis.opendocument.spreadsheet,
application/vnd.oasis.opendocument.presentation,
application/visio,application/vnd.visio,
application/vst,
application/vnd.visio.webdrawing,
application/x-mspublisher