HTML <form> acceptAttribute

HTML form 标签参考手册HTML <form> Tag

Example

Specifies that the server only accepts GIF and JPEG files for file upload:

<form action="form_action.html" accept="image/gif,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="提交">
</form>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Note:Almost all mainstream browsers do not support the accept attribute.


Definition and Usage

In HTML5, the <form> accept attribute is not supported.

The accept attribute specifies the types of files that the server accepts and that can be submitted through file upload.

Tip:Avoid using this attribute as a validation tool. You should validate file uploads on the server side.


Syntax

<form accept="MIME_type">

Attribute Values

Value Description
MIME_type One or more MIME types allowed to be submitted/uploaded. To specify multiple MIME types, separate them with commas.

See alsoIANA MIME typesto get the complete list of standard MIME types.



HTML form 标签参考手册HTML <form> Tag Other Extensions