首頁 > 後端開發 > php教程 > PHP取得檔案的mime type類型

PHP取得檔案的mime type類型

WBOY
發布: 2016-07-25 08:45:19
原創
2309 人瀏覽過
  1. /**
  2. * 取得文件的mime type類型
  3. * @author xiaobing.meng
  4. *
  5. */
  6. class MimeTypes {
  7. public static $mime_types = array (
  8. 'apk' = > 'application/vnd.android.package-archive',
  9. '3gp' => '影片/3gpp',
  10. 'ai' => '應用程式/postscript',
  11. 'aif' => '音訊/x-aiff',
  12. 'aifc' => '音訊/x-aiff',
  13. 'aiff' => '音訊/x-aiff',
  14. 'asc ' => '文字/純文字',
  15. 'atom' => '應用程式/atom xml',
  16. 'au' => '音訊/基本',
  17. 'avi' =>; 'video/x-msvideo' ,
  18. 'bcpio' => 'application/x-bcpio',
  19. 'bin' => 'application/octet-stream',
  20. 'bmp' => ; '圖片/bmp',
  21. 'cdf' => '應用程式/x-netcdf',
  22. 'cgm' => '圖片/cgm',
  23. '類別' => '應用程式' /octet-stream',
  24. 'cpio' => 'application/x-cpio',
  25. 'cpt' => 'application/mac-compactpro',
  26. 'csh' => ' application/x-csh',
  27. 'css ' => 'text/css',
  28. 'dcr' => 'application/x-director',
  29. 'dif' =>; 'video/x-dv',
  30. 'dir' => ; 'application/x-director',
  31. 'djv' =>; 'image/vnd.djvu',
  32. 'djvu' =>; 'image/vnd.djvu',
  33. 'dll' = >; 'application/octet-stream',
  34. 'dmg' =>; 'application/octet-stream',
  35. 'dms' =>; 'application/octet-stream',
  36. 'doc' =>; 'application/msword',
  37. 'dtd' =>; 'application/xml-dtd',
  38. 'dv' =>; 'video/x-dv',
  39. 'dvi' = >; 'application/x-dvi',
  40. 'dxr' =>; 'application/x-director',
  41. 'eps' =>; 'application/postscript',
  42. 'etx' => ; 'text/x-setext',
  43. 'exe' =>; 'application/octet-stream',
  44. 'ez' =>; 'application/andrew-inset',
  45. 'flv' = >; 'video/x-flv',
  46. 'gif' =>; 'image/gif',
  47. 'gram' =>; 'application/srgs',
  48. 'grxml' =>; ' application/srgs xml',
  49. 'gtar' =>; 'application/x-gtar',
  50. 'gz' =>; 'application/x-gzip',
  51. 'hdf' =>; ' application/x-hdf',
  52. 'hqx' =>; 'application/mac-binhex40',
  53. 'htm' =>; 'text/html',
  54. 'html' =>; 'text /html',
  55. 'ice' =>; 'x-conference/x-cooltalk',
  56. 'ico' =>; 'image/x-icon',
  57. 'ics' =>; '文字/日曆',
  58. 'ief' =>; 'image/ief',
  59. 'ifb' =>; '文字/日曆',
  60. 'iges' =>; '模型/iges',
  61. 'igs' =>; '模型/iges',
  62. 'jnlp' =>; 'application/x-java-jnlp-file',
  63. 'jp2' =>; 'image/jp2' ,
  64. 'jpe' =>; 'image/jpeg',
  65. 'jpeg' =>; 'image/jpeg',
  66. 'jpg' =>; 'image/jpeg',
  67. ' js' =>; 'application/x-javascript',
  68. 'kar' =>; '音頻/midi',
  69. '乳膠' =>; 'application/x-latex',
  70. 'lha ' =>; 'application/octet-stream',
  71. 'lzh' =>; 'application/octet-stream',
  72. 'm3u' =>; 'audio/x-mpegurl',
  73. ' m4a' =>; '音訊/mp4a-latm',
  74. 'm4p' =>; '音訊/mp4a-latm',
  75. 'm4u' =>; 'video/vnd.mpegurl',
  76. 'm4v' =>; 'video/x-m4v',
  77. 'mac' =>; 'image/x-macpaint',
  78. 'man' =>; 'application/x-troff-man',
  79. 'mathml' =>; 'application/mathml xml',
  80. '我' =>; 'application/x-troff-me',
  81. 'mesh' =>; '模型/網格' ,
  82. 'mid' =>; '音頻/midi',
  83. 'midi' =>; '音頻/midi',
  84. 'mif' =>; 'application/vnd.mif',
  85. 'mov' =>; '視頻/quicktime',
  86. '電影' =>; 'video/x-sgi-movie',
  87. 'mp2' =>; '音頻/mpeg',
  88. 'mp3' =>; '音訊/mpeg',
  89. 'mp4' =>; '視訊/mp4',
  90. 'mpe' =>; '視訊/mpeg',
  91. 'mpeg' => ; '視訊/mpeg',
  92. 'mpg' =>; '視訊/mpeg',
  93. 'mpga' =>; '音訊/mpeg',
  94. 'ms' => 'application/x- troff-ms',
  95. 'msh' =>; '模型/網格',
  96. 'mxu' =>; 'video/vnd.mpegurl',
  97. 'nc' =>; 'application/ x-netcdf',
  98. 'oda' =>; 'application/oda',
  99. 'ogg' =>; 'application/ogg',
  100. 'ogv' =>; '影片/ogv',
  101. 'pbm' =>; 'image/x-portable-bitmap',
  102. 'pct' =>; '圖片/圖片',
  103. 'pdb' =>; 'chemical/x-pdb' ,
  104. 'pdf' =>; 'application/pdf',
  105. 'pgm' =>; 'image/x-portable-graymap',
  106. 'pgn' =>; 'application/x-chess -pgn',
  107. 'pic' =>; '圖片/圖片',
  108. '圖片' => '圖片/圖片',
  109. 'png' =>; 'image/png',
  110. 'pnm' =>; 'image/x-portable-anymap',
  111. 'pnt ' =>; 'image/x-macpaint',
  112. 'pntg' =>; 'image/x-macpaint',
  113. 'ppm' =>; 'image/x-portable-pixmap',
  114. 'ppt' =>; 'application/vnd.ms-powerpoint',
  115. 'ps' =>; 'application/postscript',
  116. 'qt' =>; '影片/quicktime',
  117. 'qti' =>; 'image/x-quicktime',
  118. 'qtif' =>; 'image/x-quicktime',
  119. 'ra' =>; 'audio/x-pn-realaudio',
  120. 'ram' =>; 'audio/x-pn-realaudio',
  121. 'ras' =>; 'image/x-cmu-raster',
  122. 'rdf' =>; 'application/ rdf xml',
  123. 'rgb' =>; 'image/x-rgb',
  124. 'rm' =>; 'application/vnd.rn-realmedia',
  125. 'roff' =>; ' application/x-troff',
  126. 'rtf' =>; 'text/rtf',
  127. 'rtx' =>; 'text/richtext',
  128. 'sgm' =>; 'text/sgml ',
  129. 'sgml' =>; 'text/sgml',
  130. 'sh' =>; 'application/x-sh',
  131. 'shar' =>; 'application/x-shar' ,
  132. '筒倉' =>; '模型/網格',
  133. '坐' => 'application/x-stuffit',
  134. 'skd' =>; 'application/x-koan' ,
  135. 'skm' =>; 'application/x-koan',
  136. 'skp' =>; 'application/x-koan',
  137. 'skt' =>; 'application/x-koan ',
  138. 'smi' =>; 'application/smil',
  139. 'smil' =>; 'application/smil',
  140. 'snd' =>; '音訊/基本',
  141. '所以' => 'application/octet-stream',
  142. 'spl' =>; 'application/x-futuresplash',
  143. 'src' =>; 'application/x-wais-source',
  144. 'sv4cpio' =>; 'application/x-sv4cpio',
  145. 'sv4crc' =>; 'application/x-sv4crc',
  146. 'svg' =>; 'image/svg xml',
  147. 'swf' =>; 'application/x-shockwave-flash',
  148. 't' =>; 'application/x-troff',
  149. 'tar' =>; 'application/x-tar ',
  150. 'tcl' =>; 'application/x-tcl',
  151. 'tex' =>; 'application/x-tex',
  152. 'texi' =>; 'application/x- texinfo',
  153. 'texinfo' =>; 'application/x-texinfo',
  154. 'tif' =>; '圖像/tiff',
  155. 'tiff' =>; 'image/tiff',
  156. 'tr' =>; 'application/x-troff',
  157. 'tsv' =>; '文字/製表符分隔值',
  158. 'txt' =>; 'text/plain' ,
  159. 'ustar' =>; 'application/x-ustar',
  160. 'vcd' =>; 'application/x-cdlink',
  161. 'vrml' =>; '模型/vrml',
  162. 'vxml' =>; 'application/voicexml xml',
  163. 'wav' =>; '音訊/x-wav',
  164. 'wbmp' => 'image/vnd.wap.wbmp' ,
  165. 'wbxml' =>; 'application/vnd.wap.wbxml',
  166. 'webm' =>; '視訊/webm',
  167. 'wml' =>; 'text/vnd.wap .wml',
  168. 'wmlc' =>; 'application/vnd.wap.wmlc',
  169. 'wmls' =>; 'text/vnd.wap.wmlscript',
  170. 'wmlsc' => ; 'application/vnd.wap.wmlscriptc',
  171. 'wmv' =>; 'video/x-ms-wmv',
  172. 'wrl' =>; '模型/vrml',
  173. 'xbm ' =>; 'image/x-xbitmap',
  174. 'xht' =>; 'application/xhtml xml',
  175. 'xhtml' =>; 'application/xhtml xml',
  176. 'xls' =>; 'application/vnd.ms-excel',
  177. 'xml' =>; 'application/xml',
  178. 'xpm' =>; 'image/x-xpixmap',
  179. 'xsl ' =>; 'application/xml',
  180. 'xslt' =>; 'application/xslt xml',
  181. 'xul' =>; 'application/vnd.mozilla.xul xml',
  182. ' xwd' =>; 'image/x-xwindowdump',
  183. 'xyz' =>; 'chemical/x-xyz',
  184. 'zip' =>; 'application/zip' );
  185. public static function get_mimetype($ext) {
  186. return (isset ( self::$mime_types [$ext] ) ? self::$mime_types [$ext] : 'application/octet-stream');
  187. }
  188. }
複製程式碼

PHP、mime、型


來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板