HTML input accept property
Examples
Specified in the file upload server only accepts image files:
<form action="demo_form.html">
<input type="file" name="pic" accept="image/*">
<input type="submit">
</form>
<input type="file" name="pic" accept="image/*">
<input type="submit">
</form>
try it"
Browser Support
Internet Explorer 10, Firefox, Opera, Chrome and Safari 6 supports accept property.
Note: 9 and earlier versions of Internet Explorer do not support accept attribute <input> tag.
Definition and Usage
accept attribute specifies acceptable by the server file upload documents submitted type.
NOTE: accept property applies only to <input type = "file"> .
Tip: Do not use this property as your verification tool. It should be on the server for file upload verification.
Differences between HTML 4.01 and HTML5
no.
grammar
<input accept="audio/*|video/*|image/*|MIME_type">
Tip: For more than a predetermined value, use a comma-separated value (eg <input accept = "audio / * , video / *, image / *" />).
Property Value
值 | 描述 |
---|---|
audio/* | 接受所有的声音文件。 |
video/* | 接受所有的视频文件。 |
image/* | 接受所有的图像文件。 |
MIME_type | 一个有效的 MIME 类型,不带参数。请参阅 IANA MIME 类型 ,获得标准 MIME 类型的完整列表。 |
HTML <input> tag