input标签中的accpet

用法

accept 属性只能与 <input type="file"> 配合使用。它规定能够通过文件上传进行提交的文件类型。

提示:请避免使用该属性。应该在服务器端验证文件上传。

如果不限制图像的格式,可以写为:accept="image/*"

在文件上传中使用 accept 属性,本例中的输入字段可以接受 GIF 和 JPEG 两种图像:

<form>
  <input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" />
</form>
原文地址:https://www.cnblogs.com/ly-lyq/p/9254988.html