将此用于我的文件输入中的accept字段:
using this for the accept field in my file input:
application/zip,application/x-zip,application/x-zip-compressed,application/octet-stream结果:
- Internet Explorer:仅显示.zip.是的.
- FireFox:显示所有文件,但我可以将下拉列表更改为仅显示.zip.我可以通过某种方式将.zip更改为默认视图吗?
- Chrome:显示.zip和.exe.如何排除.exe?
我知道chrome在技术上是正确的,但是我想在这里做到用户友好.
I know chrome is technically right, but I'm trying to be user friendly here.
推荐答案application/octet-stream是包罗万象"存储桶.如果文件名没有扩展名来帮助确定它,则它是默认的mime类型.我猜这也是您的EXE在Chrome中的表示形式.
application/octet-stream is the "catch-all" bucket. It's the default mime-type if the filename has no extension to help determine it. It's also the source of your EXE representation in Chrome, I'm guessing.
使用< input type ="file" ;> ;?
您也可以尝试使用INPUT/File上的"accept"属性来减少它.上面的链接还有指向您可以播放和测试的JSFiddle页面的链接.
You can also try reducing it with the "accept" attribute on the INPUT/File. That link above also has a link to a JSFiddle page you can play and test with.
更多推荐
HTML文件输入仅接受.zip文件(不接受.exe)
发布评论