input file弹出框选择文件后缀限制

在页面选择文件时的弹出框默认显示的是所有类型的文件,有时候文件太多不好选择,我们就要过滤掉不想展示的文件,这是需要用到input的accept属性,只有在type="file"才有效

菜鸟教程:https://www.runoob.com/tags/att-input-accept.html

网友博客:https://blog.csdn.net/u013379933/article/details/77119796

但是,我原本打算是想过滤 (.exe、.sh、.py)这些类型的文件,发现里面都没有。后来找到下面这篇博客:

https://www.cnblogs.com/haocool/p/3431181.html

灵机一动,改成如下形式测试通过:

<input type="file" id="file" accept=".bat,.c,.sh,.exe,.ps1,.py,.jar">

 

posted @ 2018-05-22 17:23  山水花草  阅读(851)  评论(0)    收藏  举报