accept
On this page
HTML accept Attribute (HTML接受属性)
The HTML accept attribute specifies the type of file that the server accepts. The submission is possible through a file upload. (HTML accept属性指定服务器接受的文件类型。可以通过文件上传提交。)
You can only use this attribute on the <input> element. It is only used with <input type=“file”>.
The accept attribute must not be used as a validation tool. File uploads must be validated on the server. (Accept属性不得用作验证工具。文件上传必须在服务器上验证。)
Syntax
Syntax (语法)
<input accept="file_extension | audio/* | video/* | image/* | media_type">
Example of the HTML accept attribute:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<form action="/form/submit" method="post">
<input type="file" name="Image" accept="image/*">
<input type="submit">
</form>
</body>
</html>