input file上传类型控制

2019年9月11日08:10:24 2 122

项目需求有时候会要求对上传文件的类型进行控制,防止瞎上传文件.

  1. <input type="file" name=""  id="" accept="image/*" >

type=file 代表上传文件

accept='' 代表上传文件限制,这里image/*代表全部图片类型

文件类型accept
*.3gppaudio/3gpp, video/3gpp
.ac3audio/ac3
.asfallpication/vnd.ms-asf
.auaudio/basic
.csstext/css
.csvtext/csv
.docapplication/msword
.dotapplication/msword
.dtdapplication/xml-dtd
.dwgimage/vnd.dwg
.dxfimage/vnd.dxf
.gifimage/gif
.htmtext/html
.htmltext/html
.jp2image/jp2
.jpeimage/jpeg
.jpegimage/jpeg
.jpgimage/jpeg
.jstext/javascript, application/javascript
.jsonapplication/json
.mp2audio/mpeg, video/mpeg
.mp3audio/mpeg
.mp4audio/mp4, video/mp4
.mpegvideo/mpeg
.mpgvideo/mpeg
.mppapplication/vnd.ms-project
.oggapplication/ogg, audio/ogg
.pdfapplication/pdf
.pngimage/png
.potapplication/vnd.ms-powerpoint
.ppsapplication/vnd.ms-powerpoint
.pptapplication/vnd.ms-powerpoint
.rtfapplication/rtf, text/rtf
.svfimage/vnd.svf
.tifimage/tiff
.tiffimage/tiff
.txttext/plain
.wdbapplication/vnd.ms-works
.wpsapplication/vnd.ms-works
.xhtmlapplication/xhtml+xml
.xlcapplication/vnd.ms-excel
.xlmapplication/vnd.ms-excel
.xlsapplication/vnd.ms-excel
.xltapplication/vnd.ms-excel
.xlwapplication/vnd.ms-excel
.xmltext/xml, application/xml
.zipapplication/zip
.xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltxapplication/vnd.openxmlformats-officedocument.spreadsheetml.template
.potxapplication/vnd.openxmlformats-officedocument.presentationml.template
.ppsxapplication/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptxapplication/vnd.openxmlformats-officedocument.presentationml.presentation
.sldxapplication/vnd.openxmlformats-officedocument.presentationml.slide
.docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotxapplication/vnd.openxmlformats-officedocument.wordprocessingml.template
.xlsmapplication/vnd.ms-excel.addin.macroEnabled.12
.xlsbapplication/vnd.ms-excel.sheet.binary.macroEnabled.12

 

weinxin
微信公众号
博客微信公众号,欢迎关注。
不忘初心 牢记使命

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:2   其中:访客  2   博主  0

    • avatar 小姚工作室 2

      很实用

      • avatar 黑帽SEO网赚 1

        好文,欢迎回访