1、IIS 添加 MIME 类型支持 rmvb 等播放环境:Win7 、IIS7.5添加 MIME 类型:文件扩展名: .rmvbMIME 类型: application/vnd.rn-realmedia$mime = array (003 /applications004 ai = application/postscript,005 eps = application/postscript,006 exe = application/octet-stream,007 doc = application/vnd.ms-word,008 xls = application/vnd.ms-excel
2、,009 ppt = application/vnd.ms-powerpoint,010 pps = application/vnd.ms-powerpoint,011 pdf = application/pdf,012 xml = application/xml,013 odt = application/vnd.oasis.opendocument.text,014 swf = application/x-shockwave-flash,015 / archives016 gz = application/x-gzip,017 tgz = application/x-gzip,018 bz
3、 = application/x-bzip2,019 bz2 = application/x-bzip2,020 tbz = application/x-bzip2,021 zip = application/zip,022 rar = application/x-rar,023 tar = application/x-tar,024 7z = application/x-7z-compressed,025 / texts026 txt = text/plain,027 php = text/x-php,028 html = text/html,029 htm = text/html,030
4、js = text/javascript,031 css = text/css,032 rtf = text/rtf,033 rtfd = text/rtfd,034 py = text/x-python,035 java = text/x-java-source,036 rb = text/x-ruby,037 sh = text/x-shellscript,038 pl = text/x-perl,039 sql = text/x-sql,040 / images041 bmp = image/x-ms-bmp,042 jpg = image/jpeg,043 jpeg = image/j
5、peg,044 gif = image/gif,045 png = image/png,046 tif = image/tiff,047 tiff = image/tiff,048 tga = image/x-targa,049 psd = image/vnd.adobe.photoshop,050 /audio051 mp3 = audio/mpeg,052 mid = audio/midi,053 ogg = audio/ogg,054 mp4a = audio/mp4,055 wav = audio/wav,056 wma = audio/x-ms-wma,057 / video058
6、avi = video/x-msvideo,059 dv = video/x-dv,060 mp4 = video/mp4,061 mpeg = video/mpeg,062 mpg = video/mpeg,063 mov = video/quicktime,064 wm = video/x-ms-wmv,065 flv = video/x-flv,066 mkv = video/x-matroska067 );068 069 function _getMimeDetect() 070 if (class_exists(finfo) 071 return finfo;072 else if
7、(function_exists(mime_content_type) 073 return mime_content_type;074 else if ( function_exists(exec) 075 $result = exec(file -ib .escapeshellarg(_FILE_);076 if ( 0 = strpos($result, text/x-php) OR 0 = strpos($result, text/x-c+) 077 return linux;078 079 $result = exec(file -Ib .escapeshellarg(_FILE_)
8、;080 if ( 0 = strpos($result, text/x-php) OR 0 = strpos($result, text/x-c+) 081 return bsd;082 083 084 return internal;085 086 087 function _getMimeType($path) 088 global $mime;089 $fmime = _getMimeDetect();090 switch($fmime) 091 case finfo:092 $finfo = finfo_open(FILEINFO_MIME);093 if ($finfo)094 $
9、type = finfo_file($finfo, $path);095 break;096 case mime_content_type:097 $type = mime_content_type($path);098 break;099 case linux:100 $type = exec(file -ib .escapeshellarg($path);101 break;102 case bsd:103 $type = exec(file -Ib .escapeshellarg($path);104 break;105 default:106 $pinfo = pathinfo($pa
10、th);107 $ext = isset($pinfoextension) ? strtolower($pinfoextension) : ;108 $type = isset($mime$ext) ? $mime$ext : unkown;109 break;110 111 $type = explode(;, $type);112 113 /需要加上这段,因为如果使用 mime_content_type函数来获取一个不存在的$path 时会返回application/octet-stream114 if ($fmime != internal AND $type0 = applicatio
11、n/octet-stream) 115 $pinfo = pathinfo($path);116 $ext = isset($pinfoextension) ? strtolower($pinfoextension) : ;117 if (!empty($ext) AND !empty($mime$ext) 118 $type0 = $mime$ext;119 120 121 122 return $type0;123 124 125 $path = 1.txt; /实际上当前路径并不存在 1.txt126 var_dump(_getMimeType($path);127 128 /*End of php*/