文件类型限制参考
在上传文件过程中,设计需求上这边总是需要对上传文件进行限制和判断,避免用户的盲操作,导致上传文件类型不对后,无法得到正确的信息,造成不好的体验影响,所以在页面上我们需要对文件类型做判断。
-
Image
格式:'png' => 'image/png
'bmp' => 'image/bmp'
'gif' => 'image/gif'
'ico' => 'image/x-icon'
'tif|tiff' => 'image/tiff'
'jpg|jpeg|jpe' => 'image/jpeg'
-
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'
-
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'
-
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'
-
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'
-
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'
-
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'
-
Word Perfect
格式'wp|wpd' => 'application/wordperfect'