前言
前端选择文件时,都会使用 input 框设定 type="file" 来选择文件,默认情况下可以选择所有类型的文件,有时候需要限定选择的文件类型,这时候就用到了 accept 属性。
ps:accept 属性仅适用于 <input type="file"/>
accept 各种类型
文件类型 | accept 属性值(多个值之间以逗号隔开) |
---|---|
.3gpp | audio/3gpp, video/3gpp |
.ac3 | audio/ac3 |
.asf | allpication/vnd.ms-asf |
.au | audio/basic |
.css | text/css |
.csv | text/csv |
.doc | application/msword |
.docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
.dot | application/msword |
.dotx | application/vnd.openxmlformats-officedocument.wordprocessingml.template |