HTML 标签的 accept 属性
<form> <input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" /> </form>
accept 属性只能与 <input type="file"> 配合使用。它规定能够通过文件上传进行提交的文件类型。
值 | 描述 |
---|---|
audio/* | 接受所有的声音文件。 |
video/* | 接受所有的视频文件。 |
image/* | 接受所有的图像文件。 |
mime_type | 一个有效的 mime 类型,不带参数。请参阅 iana mime 类型,获得标准 mime 类型的完整列表。 |
accept可以指定如下信息:
*.3gpp | audio/3gpp, video/3gpp | 3gpp audio/video |
*.ac3 | audio/ac3 | ac3 audio |
*.asf | allpication/vnd.ms-asf | advanced streaming format |
*.au | audio/basic | au audio |
*.css | text/css | cascading style sheets |
*.csv | text/csv | comma separated values |
*.doc | application/msword | ms word document |
*.dot | application/msword | ms word template |
*.dtd | application/xml-dtd | document type definition |
*.dwg | image/vnd.dwg | autocad drawing database |
*.dxf | image/vnd.dxf | autocad drawing interchange format |
*.gif | image/gif | graphic interchange format |
*.htm | text/html | hypertext markup language |
*.html | text/html | hypertext markup language |
*.jp2 | image/jp2 | jpeg-2000 |
*.jpe | image/jpeg | jpeg |
*.jpeg | image/jpeg | jpeg |
*.jpg | image/jpeg | jpeg |
*.js | text/javascript, application/javascript | javascript |
*.json | application/json | javascript object notation |
*.mp2 | audio/mpeg, video/mpeg | mpeg audio/video stream, layer ii |
*.mp3 | audio/mpeg | mpeg audio stream, layer iii |
*.mp4 | audio/mp4, video/mp4 | mpeg-4 audio/video |
*.mpeg | video/mpeg | mpeg video stream, layer ii |
*.mpg | video/mpeg | mpeg video stream, layer ii |
*.mpp | application/vnd.ms-project | ms project project |
*.ogg | application/ogg, audio/ogg | ogg vorbis |
application/pdf | portable document format | |
*.png | image/png | portable network graphics |
*.pot | application/vnd.ms-powerpoint | ms powerpoint template |
*.pps | application/vnd.ms-powerpoint | ms powerpoint slideshow |
*.ppt | application/vnd.ms-powerpoint | ms powerpoint presentation |
*.rtf | application/rtf, text/rtf | rich text format |
*.svf | image/vnd.svf | simple vector format |
*.tif | image/tiff | tagged image format file |
*.tiff | image/tiff | tagged image format file |
*.txt | text/plain | plain text |
*.wdb | application/vnd.ms-works | ms works database |
*.wps | application/vnd.ms-works | works text document |
*.xhtml | application/xhtml+xml | extensible hypertext markup language |
*.xlc | application/vnd.ms-excel | ms excel chart |
*.xlm | application/vnd.ms-excel | ms excel macro |
*.xls | application/vnd.ms-excel | ms excel spreadsheet |
*.xlt | application/vnd.ms-excel | ms excel template |
*.xlw | application/vnd.ms-excel | ms excel workspace |
*.xml | text/xml, application/xml | extensible markup language |
*.zip | application/zip | compressed archive |
除了以上的类型外,2007后各文档如docx需配置的accept属性值如下:
extension mime type
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.sldx application/vnd.openxmlformats-officedocument.presentationml.slide
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.xlsm application/vnd.ms-excel.addin.macroenabled.12
.xlsb application/vnd.ms-excel.sheet.binary.macroenabled.12