<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
*.pdf 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

最新文章

  1. 关于vue.js中列表渲染练习
  2. node服务器
  3. Bindless Textures
  4. 基于Jquery-ui的自动补全
  5. HTML统一资源定位器
  6. 线段树---HDU2795Billboard
  7. Stack and queue.
  8. Unity调试中心
  9. Java IO流之普通文件流和随机读写流区别
  10. 利用大白菜制作多系统启动U盘(win+ubuntu+PE+...)
  11. ASP.NET 应用程序遭遇Server Application Unavailable问题的解决的方法
  12. dos命令dir查找文件的用法及实例
  13. 解决无法连接到 reCAPTCHA 服务
  14. python 实现有序字典
  15. 没有使用Material组件和使用了的对比
  16. iproute2 与 net-tools
  17. EF Core 新特性——Owned Entity Types
  18. ARM 汇编的mov操作立即数的疑问
  19. 1108 Finding Average (20 分)
  20. StringUtils学习

热门文章

  1. Jsonp的js实现,跨域请求,同源策略机制
  2. 在kubernetes 集群内访问k8s API服务
  3. Elasticsearch系列---初识Elasticsearch
  4. Angular常用VSCode插件
  5. SSM框架之SpringMVC(4)返回值类型及响应数据类型
  6. 最近几周,写了个微信好友检测助手App
  7. 给spark submit main传递参数
  8. Spring源码解析-ioc容器的设计
  9. Attention 和self-attention
  10. CMKAE简单实用指南