HTML文件输入仅接受.zip文件(不接受.exe)

编程入门 行业动态 更新时间:2024-10-28 18:25:10
本文介绍了HTML文件输入仅接受.zip文件(不接受.exe)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

将此用于我的文件输入中的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)

本文发布于:2023-11-08 18:45:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1570131.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   不接受   HTML   exe   zip

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!