English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The accept attribute specifies the file types that the server accepts (files can be submitted through file upload), please avoid using this attribute as a validation tool. File uploads should be validated on the server side to prevent malicious uploads.
Specify the server to accept only png and jpeg image formats when uploading files:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML <form> accept Attribute Usage-Basic Tutorial(oldtoolbag.com)</title> </head> <body> <form action="action_page.php" accept="image/png, image/jpeg"> First name: <input type="text" name="fname"><br> Last name: <input type="text" name="lname"><br> Your image: <input type="file" name="pic" id="pic"><br> <input type="submit" value="Submit"> </form> </body> </html>Test it out ‹/›
IEFirefoxOperaChromeSafari
Note:Almost all mainstream browsers do not support the accept attribute.
In HTML5 In,the <form> accept attribute is not supported.
The accept attribute specifies the file types accepted by the server (files can be submitted through file upload).
Tip:Avoid using this attribute as a validation tool; it should be validated on the server side when uploading files.
<form accept="MIME_type">
Value | Description |
---|---|
MIME_type | Allowed to be submitted/One or more MIME types uploaded. To specify multiple MIME types, separate them with commas. See IANA MIME Types,for a complete list of standard MIME types. |