English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The accept attribute specifies the filter for the file types that users can select from the file input dialog (only for type ="file"), note: the accept attribute can only be used with <input type ="file">
Specify the file types that users can select from the file input dialog:
<!DOCTYPE html> <html> <head> <title>HTML: <input> accept attribute - 基础教程网(oldtoolbag.com)</title> <body> <form action="action_page.php"> <input type="file" name="pic" accept="image/*"> <input type="submit"> </form> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 10, Firefox, Opera, Chrome and Safari 6 Supports the accept attribute.
Note:Internet Explorer 9 Previous versions do not support the accept attribute of the <input> tag.
accept属性为用户可以从文件输入对话框中选择的文件类型指定过滤器(仅用于type ="file")。
注意: accept属性只能与<input type ="file">一起使用。
提示:请勿将此属性用作验证工具。文件上传应在服务器上验证,以保证上传的安全性。
没有。
<input accept="audio/*|video/*|image/*|MIME_type">
提示:如果要指定多个值,请用逗号分隔这些值(比如 <input accept="audio/*,video/*,image/*" />)。
值 | 描述 |
---|---|
audio/* | 接受所有的声音文件。 |
video/* | 接受所有的视频文件。 |
image/* | 接受所有的图像文件。 |
MIME_type | 一个有效的 MIME 类型,不带参数。请参阅 IANA MIME 类型,获取标准 MIME 类型的完整列表。 |