HTML accept 属性
❮ 属性 ❯
定义和用法
accept 属性指定服务器接受的文件类型(可以通过文件上传提交)。
注意: accept 属性只能与 <input type="file"> 一起使用。
提示: 不要将此属性用作验证工具。文件上传应在服务器端进行验证。
适用范围
accept 属性可用于以下元素:
元素 | Attribute |
---|---|
<input> | accept |
示例
Input 示例
指定服务器仅接受文件上传中的图像文件
<form action="/action_page.php">
<input type="file" name="pic" accept="image/*">
<input type="submit">
</form>
自己动手试一试 »
浏览器支持
表格中的数字表示完全支持该属性的第一个浏览器版本。
Attribute | |||||
---|---|---|---|---|---|
accept | 8.0 | 10.0 | 4.0 | 6.0 | 15.0 |
❮ 属性 ❯