accept属性设置 <input type="file" accept="image/*" />

[复制链接]
陈家粉儿Lv.7 显示全部楼层 发表于 2021-11-11 17:58:49 |阅读模式 打印 上一主题 下一主题
苹果上架
accept属性设置 <input type="file" accept="image/*" />   限制单个或多个文件类型
  1. 在上传文件的时候,需要限制指定的文件类型。
  2. <input type="file" accept="image/*" />   
  3. accept表示可以上传文件类型,image表示图片,*表示所有支持的格式。
复制代码



[taBLE]
[tr][td]
文件类型
[/td][td]
写法
[/td][td]
解释
[/td][/tr]
[tr][td]
*.3gpp
[/td][td]
audio/3gpp, video/3gpp
[/td][td]
3GPP Audio/Video
[/td][/tr]
[tr][td]
*.ac3
[/td][td]
audio/ac3
[/td][td]
AC3 Audio
[/td][/tr]
[tr][td]
*.asf
[/td][td]
allpication/vnd.ms-asf
[/td][td]
Advanced Streaming Format
[/td][/tr]
[tr][td]
*.au
[/td][td]
audio/basic
[/td][td]
AU Audio
[/td][/tr]
[tr][td]
*.css
[/td][td]
text/css
[/td][td]
Cascading Style Sheets
[/td][/tr]
[tr][td]
*.csv
[/td][td]
text/csv
[/td][td]
Comma Separated Values
[/td][/tr]
[tr][td]
*.doc
[/td][td]
APPlication/msword
[/td][td]
MS Word Document
[/td][/tr]
[tr][td]
*.dot
[/td][td]
application/msword
[/td][td]
MS Word Template
[/td][/tr]
[tr][td]
*.dtd
[/td][td]
application/xml-dtd
[/td][td]
Document Type Definition
[/td][/tr]
[tr][td]
*.dwg
[/td][td]
image/vnd.dwg
[/td][td]
AutoCAD Drawing Database
[/td][/tr]
[tr][td]
*.dxf
[/td][td]
image/vnd.dxf
[/td][td]
AutoCAD Drawing Interchange Format
[/td][/tr]
[tr][td]
*.gif
[/td][td]
image/gif
[/td][td]
Graphic Interchange Format
[/td][/tr]
[tr][td]
*.htm
[/td][td]
text/html
[/td][td]
HyperText Markup Language
[/td][/tr]
[tr][td]
*.html
[/td][td]
text/html
[/td][td]
HyperText Markup Language
[/td][/tr]
[tr][td]
*.jp2
[/td][td]
image/jp2
[/td][td]
JPEG-2000
[/td][/tr]
[tr][td]
*.jpe
[/td][td]
image/jpeg
[/td][td]
JPEG
[/td][/tr]
[tr][td]
*.jpeg
[/td][td]
image/jpeg
[/td][td]
JPEG
[/td][/tr]
[tr][td]
*.jpg
[/td][td]
image/jpeg
[/td][td]
JPEG
[/td][/tr]
[tr][td]
*.js
[/td][td]
text/javascript, application/javascript
[/td][td]
JavaScript
[/td][/tr]
[tr][td]
*.json
[/td][td]
application/json
[/td][td]
JavaScript Object Notation
[/td][/tr]
[tr][td]
*.mp2
[/td][td]
audio/mpeg, video/mpeg
[/td][td]
MPEG Audio/Video Stream, Layer II
[/td][/tr]
[tr][td]
*.mp3
[/td][td]
audio/mpeg
[/td][td]
MPEG Audio Stream, Layer III
[/td][/tr]
[tr][td]
*.mp4
[/td][td]
audio/mp4, video/mp4
[/td][td]
MPEG-4 Audio/Video
[/td][/tr]
[tr][td]
*.mpeg
[/td][td]
video/mpeg
[/td][td]
MPEG Video Stream, Layer II
[/td][/tr]
[tr][td]
*.mpg
[/td][td]
video/mpeg
[/td][td]
MPEG Video Stream, Layer II
[/td][/tr]
[tr][td]
*.mpp
[/td][td]
application/vnd.ms-project
[/td][td]
MS Project Project
[/td][/tr]
[tr][td]
*.ogg
[/td][td]
application/ogg, audio/ogg
[/td][td]
Ogg Vorbis
[/td][/tr]
[tr][td]
*.pdf
[/td][td]
application/pdf
[/td][td]
Portable Document Format
[/td][/tr]
[tr][td]
*.png
[/td][td]
image/png
[/td][td]
Portable Network Graphics
[/td][/tr]
[tr][td]
*.pot
[/td][td]
application/vnd.ms-powerpoint
[/td][td]
MS PowerPoint Template
[/td][/tr]
[tr][td]
*.pps
[/td][td]
application/vnd.ms-powerpoint
[/td][td]
MS PowerPoint Slideshow
[/td][/tr]
[tr][td]
*.ppt
[/td][td]
application/vnd.ms-powerpoint
[/td][td]
MS PowerPoint Presentation
[/td][/tr]
[tr][td]
*.rtf
[/td][td]
application/rtf, text/rtf
[/td][td]
Rich Text Format
[/td][/tr]
[tr][td]
*.svf
[/td][td]
image/vnd.svf
[/td][td]
Simple Vector Format
[/td][/tr]
[tr][td]
*.tif
[/td][td]
image/tiff
[/td][td]
Tagged Image Format File
[/td][/tr]
[tr][td]
*.tiff
[/td][td]
image/tiff
[/td][td]
Tagged Image Format File
[/td][/tr]
[tr][td]
*.txt
[/td][td]
text/plain
[/td][td]
Plain Text
[/td][/tr]
[tr][td]
*.wdb
[/td][td]
application/vnd.ms-works
[/td][td]
MS Works Database
[/td][/tr]
[tr][td]
*.wps
[/td][td]
application/vnd.ms-works
[/td][td]
Works Text Document
[/td][/tr]
[tr][td]
*.xhtml
[/td][td]
application/xhtml+xml
[/td][td]
Extensible HyperText Markup Language
[/td][/tr]
[tr][td]
*.xlc
[/td][td]
application/vnd.ms-excel
[/td][td]
MS Excel Chart
[/td][/tr]
[tr][td]
*.xlm
[/td][td]
application/vnd.ms-excel
[/td][td]
MS Excel Macro
[/td][/tr]
[tr][td]
*.xls
[/td][td]
application/vnd.ms-excel
[/td][td]
MS Excel Spreadsheet
[/td][/tr]
[tr][td]
*.xlt
[/td][td]
application/vnd.ms-excel
[/td][td]
MS Excel Template
[/td][/tr]
[tr][td]
*.xlw
[/td][td]
application/vnd.ms-excel
[/td][td]
MS Excel Workspace
[/td][/tr]
[tr][td]
*.xml
[/td][td]
text/xml, application/xml
[/td][td]
Extensible Markup Language
[/td][/tr]
[tr][td]
*.zip
[/td][td]
aplication/zip
[/td][td]
Compressed Archive
[/td][/tr]
[/table]
示例我们要上传TXT
.txt结尾的所有文件
<input type="file" accept="text/plain" />

如果有多个,以“,”分割即可
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

一门APP打包致力于H5混合APP基础框架领域的前沿探索,专注轻便的移动应用解决方案 提供基于HTML前端页面在各种应用层级的端延展。
  • 官方手机版

  • 微信公众号

  • 微信客服

  • Powered by Discuz! X3.4 | Copyright © 2001-2020, 一门APP. | 一门APP开发平台|热门标签
  • 蜀ICP备17005078号-4 | 川公网安备 51019002001185号 | |成都七扇门科技有限公司