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 - Basic Tutorial Website(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 10Firefox, Opera, Chrome, and Safari 6 Supports the accept attribute.
Note:Internet Explorer 9 Previous versions of the document do not support the accept attribute of the <input> tag.
The accept attribute specifies a filter for the file types that the user can select from the file input dialog (used only for type ="file").
Note: The accept attribute can only be used with <input type ="file">.
Tip: Do not use this attribute as a validation tool. File upload should be validated on the server to ensure the security of the upload.
None.
<input accept="audio/*|video/*|image/*|MIME_type">
Tip:If multiple values are to be specified, separate these values with commas (for example <input accept="audio/*,video/*,image/*" />).
Value | Description |
---|---|
audio/* | Accepts all audio files. |
video/* | Accepts all video files. |
image/* | Accepts all image files. |
MIME_type | A valid MIME type without parameters. See IANA MIME Type,to obtain a complete list of standard MIME types. |