html input file 设置文件类型
解决方案:
使用 input 的 accept 属性指定接受文件类型
-----------更新---------------
之前的代码有个缺点,打开文件窗口时会自动筛选文件夹下所有符合设定类型的文件,造成文件窗口延迟一定时间。
优化的方法是列出你需要的 详细 类型,比如:
For Image Files (.png/.jpg/etc), use: <input type="file" accept="image/x-png,image/gif,image/jpeg,image/bmp" />
这样打开的速度就快很多了
-------------之前的代码---------------------
下面是指定类型的代码:
Valid Accept Types: For CSV files (.csv), use: <input type="file" accept=".csv" />
For Excel Files 2003-2007 (.xls), use: <input type="file" accept="application/vnd.ms-excel" />
For Excel Files 2010 (.xlsx), use: <input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
For Text Files (.txt) use: <input type="file" accept="text/plain" />
For Image Files (.png/.jpg/etc), use: <input type="file" accept="image/*" />
For HTML Files (.htm,.html), use: <input type="file" accept="text/html" />
For Video Files (.avi, .mpg, .mpeg, .mp4), use: <input type="file" accept="video/*" />
For Audio Files (.mp3, .wav, etc), use: <input type="file" accept="audio/*" />
For PDF Files, use: <input type="file" accept=".pdf" />
html input file 设置文件类型的更多相关文章
- HTML5: input:file上传类型控制
ylbtech-HTML5: input:file上传类型控制 1. 一.input:file 属性返回顶部 一.input:file属性 属性值有以下几个比较常用: accept:表示可以选择的 ...
- HTML5的 input:file上传类型控制(转载)
http://www.haorooms.com/post/input_file_leixing HTML5的 input:file上传类型控制 2014年8月29日 66352次浏览 一.input: ...
- struts2 input file多文件同时通过ajax提交
<input type="file" name="files" multiple="multiple">必须是multiple才 ...
- HTML5的 input:file上传类型控制
一.input:file属性 属性值有以下几个比较常用: accept:表示可以选择的文件MIME类型,多个MIME类型用英文逗号分开,常用的MIME类型见下表. multiple:是否可以选择多个文 ...
- 动态input file多文件上传到后台没反应的解决方法!!!
其实我也不太清除具体是什么原因,但是后面就可以了!!! 我用的是springMVC 自带的文件上传 1.首先肯定是要有springMVC上传文件的相关配置! 2.前端 这是动态input file上传 ...
- php设置文件类型content-type
在PHP中可以通过header函数来发送头信息,还可以设置文件的content-type,下面整理了一些常见文件类型对于的content-type值. //date 2015-06-22//定义编码h ...
- html,图片上传预览,input file获取文件等相关操作
input file常用方法: var obj=document.getElementById("upimage"); var file=obj.files[0];//获取文件数据 ...
- file - 确定文件类型
总览 file [ -bcnsvzL ] [ -f 命名文件 ] [ -m 幻数文件 ] file ... 描述 本手册页说明了3.27版本 file 命令的使用. File 命令试图检查每个参数以判 ...
- input type="file"指定文件类型为excel
指定上传类型为excel:加上accept="application/vnd.ms-excel"即可,只兼容chrome跟ff,不兼容ie <input type=" ...
随机推荐
- unity中添加音量控制的一些步骤
1.先确认要控制的音源(Audio Source)所使用的输出(Output),例如我这里BGM使用的是MainMixer: 2.暴露音量(Volume)参数,让脚本可以控制.这里如果不暴露出来,脚本 ...
- python&selenium自动化测试实战项目
https://www.cnblogs.com/linuxchao/p/linuxchao-python-selenium-demo.html
- socket编程(python)
交互原理: 服务端和客户端通过底层socket接口编程通信,交互的信息都是通过byte字节形式传递,网络传输中不能保证信息完整传输有可能是分片传输,所以可能从缓冲区获取的信息需要分段拼接或拆分组合成一 ...
- 在多租户(容器)数据库中如何创建PDB:方法2 克隆本地PDB
基于版本:19c (12.2.0.3) AskScuti 创建方法:克隆本地PDB(从本地其他PDB创建新的PDB) 对应路径:Creating a PDB --> Cloning --> ...
- 用eclipse中自带的jetty启动项目
1.建立datasources.xml,创建jndi <jee:jndi-lookup id="datasource" jndi-name="jndiname&qu ...
- wget 显示网页内容到控制台
wget -q -O - http://www.microsoft.com
- EAC3 Transient Pre-Noise Processing
Transient pre-noise processing用于减少pre-noise的长度,pre-noise产生于low bitrate 编码存在transient matiral的场景. 当使用 ...
- 转载:声音分贝的概念,dBSPL.dBFS
转自:https://www.cnblogs.com/wangguchangqing/p/5947659.html 分贝 Decibel 分贝(dB)是一个对数单位(logarithmic unit) ...
- python SMTP发邮件
# from email.mime.text import MIMEText from email.header import Header import smtplib # sender = 'zc ...
- Hadoop中的java基本类型的序列化封装类
Hadoop将很多Writable类归入org.apache.hadoop.io包中,在这些类中,比较重要的有Java基本类.Text.Writable集合.ObjectWritable等,重点介绍J ...