文件上传限制类型参考

文件类型限制参考

在上传文件过程中,设计需求上这边总是需要对上传文件进行限制和判断,避免用户的盲操作,导致上传文件类型不对后,无法得到正确的信息,造成不好的体验影响,所以在页面上我们需要对文件类型做判断。

  1. Image 格式:

    • 'png' => 'image/png
    • 'bmp' => 'image/bmp'
    • 'gif' => 'image/gif'
    • 'ico' => 'image/x-icon'
    • 'tif|tiff' => 'image/tiff'
    • 'jpg|jpeg|jpe' => 'image/jpeg'
  2. Video 格式

    • 'avi' => 'video/avi'
    • 'ogv' => 'video/ogg'
    • 'ogv' => 'video/ogg'
    • 'flv' => 'video/x-flv'
    • 'divx' => 'video/divx'
    • 'mp4|m4v' => 'video/mp4'
    • 'mkv' => 'video/x-matroska'
    • 'mov|qt' => 'video/quicktime'
    • 'mpeg|mpg|mpe' => 'video/mpeg'
    • 'asf|asx|wax|wmv|wmx' => 'video/asf'
  3. Text 格式

    • 'csv' => 'text/csv'
    • 'css' => 'text/css'
    • 'ics' => 'text/calendar'
    • 'rtx' => 'text/richtext'
    • 'htm|html' => 'text/html'
    • 'txt|asc|c|cc|h' => 'text/plain'
    • 'tsv' => 'text/tab-separated-values'
  4. Audio 格式

    • 'wav' => 'audio/wav'
    • 'wma' => 'audio/wma'
    • 'ogg|oga' => 'audio/ogg'
    • 'mid|midi' => 'audio/midi'
    • 'mka' => 'audio/x-matroska'
    • 'mp3|m4a|m4b' => 'audio/mpeg'
    • 'ra|ram' => 'audio/x-realaudio'
  5. Misc Application 格式

    • 'rtf' => 'application/rtf'
    • 'zip' => 'application/zip'
    • 'pdf' => 'application/pdf'
    • 'rar' => 'application/rar'
    • 'tar' => 'application/x-tar'
    • 'class' => 'application/java'
    • 'js' => 'application/javascript'
    • 'gz|gzip' => 'application/x-gzip'
    • 'exe' => 'application/x-msdownload'
    • '7z' => 'application/x-7z-compressed'
    • 'swf' => 'application/x-shockwave-flash'
  6. Office 格式

    • 'doc' => 'application/msword'
    • 'wri' => 'application/vnd.ms-write'
    • 'mdb' => 'application/vnd.ms-access'
    • 'mpp' => 'application/vnd.ms-project'
    • 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel'
    • 'pot|pps|ppt' => 'application/vnd.ms-powerpoint'
    • 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote'
    • 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12'
    • 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12'
    • 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12'
    • 'docm' => 'application/vnd.ms-word.document.macroEnabled.12'
    • 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12'
    • 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12'
    • 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12'
    • 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'
    • 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12'
    • 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'
    • 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'
    • 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    • 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide'
    • 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'
    • 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template'
    • 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'
    • 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'
    • 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
    • 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
  7. Open Office 格式

    • 'odt' => 'application/vnd.oasis.opendocument.text'
    • 'odc' => 'application/vnd.oasis.opendocument.chart'
    • 'odf' => 'application/vnd.oasis.opendocument.formula'
    • 'odg' => 'application/vnd.oasis.opendocument.graphics'
    • 'odb' => 'application/vnd.oasis.opendocument.database'
    • 'ods' => 'application/vnd.oasis.opendocument.spreadsheet'
    • 'odp' => 'application/vnd.oasis.opendocument.presentation'
  8. Word Perfect 格式

    • 'wp|wpd' => 'application/wordperfect'
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值