如何过滤输入类型=“文件”按特定文件类型对话? [英] How to filter input type="file" dialog by specific file type?
问题描述
当我点击< input type =file>
的浏览按钮时,我想将浏览器限制为JPG文件。
是否可以浏览特定的文件类型? http://www.w3schools.com/tags/att_input_accept.asp :
< blockquote>
除了
Internet Explorer和Safari之外,所有主流浏览器都支持accept属性。定义和用法
accept属性指定服务器
接受的文件类型(可通过文件上传提交)。
注意:accept属性只能用于< input type =file>
。
提示:请勿将此属性用作验证工具。文件上传
应在服务器上进行验证。
语法 I want to restrict the browser to JPG files when I click on browse button of the Is it possible to browse for specific file types? See http://www.w3schools.com/tags/att_input_accept.asp: The accept attribute is supported in all major browsers, except
Internet Explorer and Safari. Definition and Usage The accept attribute specifies the types of files that the server
accepts (that can be submitted through a file upload). Note: The accept attribute can only be used with Tip: Do not use this attribute as a validation tool. File uploads
should be validated on the server. Syntax Tip: To specify more than one value, separate the values with a comma
(e.g.
这篇关于如何过滤输入类型=“文件”按特定文件类型对话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!< input accept =audio / * | video / * | image提示:要指定多个值,请使用逗号分隔
(/ *)例如< input accept =audio / *,video / *,image / */>
。
<input type="file">
.
<input type="file">
.<input accept="audio/*|video/*|image/*|MIME_type" />
<input accept="audio/*,video/*,image/*" />
.