【发布时间】:2013-02-06 07:24:00
【问题描述】:
所以我有一个标准的<input type="file" accept="..."/>,其中接受的是不同mime 类型的大列表。 我已经在服务器后端验证了文件类型,但我想确保我没有过滤掉客户端 UI 上的有效文件。我意识到旧的浏览器根本不会过滤文件,这很好。我担心的是现代浏览器可能无法识别 mime 类型并过滤掉实际有效的文件。
所以我的问题基本上是,“接受”属性有多可靠?例如,如果未安装 microsoft office,浏览器会识别 .docx mime 类型吗?此外,某些文件类型有许多不同的可能的 mime 类型与之关联,如果我只列出其中一种 mime 类型是否重要?
我不明白为什么规范最初使用 mime 类型,它会简单得多,而且我猜如果他们刚开始使用扩展名(如 chrome 接受)会更可靠。
关于我目前使用的 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
【问题讨论】:
标签: html browser mime-types html-input