Latest web development tutorials

HTML form accept property

Tag Reference HTML form HTML <form> tag

Examples

Specified in the file upload, the server accepts only gif and jpeg files:

<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"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Note: Almost all of the major browsers do not support accept property.


Definition and Usage

In HTML5 does not support <form> accept property.

accept attribute specifies the server can be submitted by file upload file types accepted.

Tip: Avoid using the property as a verification tool. You should file upload server-side validation.


grammar

<form accept="MIME_type">

Property Value

描述
MIME_type 允许被提交/被上传的一个或多个 MIME 类型。如需规定多个 MIME 类型,请使用逗号分隔它们。

请参阅 IANA MIME 类型 ,获得标准 MIME 类型的完整列表。



Tag Reference HTML form HTML <form> tag