Html杂记

1.通过accept过滤文件类型

<input type="file" id="myFile" accept="image/jpeg,image/gif,application/msword"/><br/>
在文件上传控件的accept属性中,接受以下两种格式的限制符:
  文件类型,但不限制具体扩展名,如:image/*,就只要是图片就行。
  文件类型+具体的文件扩展类型,如:image/jpeg,使用的是MIME_TYPE类型
多个MIME_TYPE类型之间用逗号分隔。

以下是几个常用的类型,其它的可以查询相关资料:
.doc                application/msword
.jpg                image/jpg
.txt                text/plain
.xls                application/vnd.ms-excel

 

posted @ 2017-07-26 14:59  GHai  阅读(123)  评论(0编辑  收藏  举报