The mimetype type of the file obtained by PHP

Source: Internet
Author: User
The mimetype type of the file obtained by PHP

  1. /**
  2. * Obtain the mime type of the object.
  3. * @ Author xiaobing. meng
  4. *
  5. */
  6. Class MimeTypes {
  7. Public static $ mime_types = array (
  8. 'Apk '=> 'application/vnd. android. package-archive ',
  9. '3gp '=> 'video/3gpp ',
  10. 'AI' => 'application/postscript ',
  11. 'Aif' => 'audio/x-aiff ',
  12. 'Aifc '=> 'audio/x-aiff ',
  13. 'Aiff '=> 'audio/x-aiff ',
  14. 'Asc '=> 'text/plain ',
  15. 'Atom '=> 'application/atom + XML ',
  16. 'Au '=> 'audio/basic ',
  17. 'Av' => 'video/x-msvideo ',
  18. 'Bcpio' => 'application/x-bcpio ',
  19. 'Bin' => 'application/octet-stream ',
  20. 'Bmp '=> 'image/bmp ',
  21. 'Cdf' => 'application/x-netcdf ',
  22. 'Cgm '=> 'image/cgm ',
  23. 'Class' => 'application/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-ctor ',
  29. 'Dif '=> 'video/x-dv ',
  30. 'Dir' => 'application/x-ctor ',
  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-ctor ',
  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 '=> 'text/calendar ',
  58. 'Ief' => 'image/ief ',
  59. 'Ifb' => 'text/calendar ',
  60. & Apos; iges & apos; = & apos; model/iges & apos ',
  61. 'Gies' => 'model/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 '=> 'audio/midi ',
  69. 'Latex '=> 'application/x-latex ',
  70. 'Lha' => 'application/octet-stream ',
  71. 'Lzh '=> 'application/octet-stream ',
  72. 'M3u' => 'audio/x-mpegurl ',
  73. 'M4a '=> 'audio/mp4a-latm ',
  74. 'M4p' => 'audio/mp4a-latm ',
  75. 'M4u' => 'video/vnd. mpegurl ',
  76. 'M4' => 'video/x-m4v ',
  77. 'Mac' => 'image/x-macpa ',
  78. 'Man '=> 'application/x-troff-man ',
  79. 'Mathm' => 'application/mathml + XML ',
  80. 'Me' => 'application/x-troff-me ',
  81. 'Mesh '=> 'model/mesh ',
  82. 'Mid '=> 'audio/midi ',
  83. 'Midi '=> 'audio/midi ',
  84. 'Mfa' => 'application/vnd. mfa ',
  85. 'Mov' => 'video/quicktime ',
  86. 'Movi' => 'video/x-sgi-Movi ',
  87. 'Mp2' => 'audio/mpeg ',
  88. 'Mp3' => 'audio/mpeg ',
  89. 'MP4' => 'video/mp4 ',
  90. 'Mpe' => 'video/mpeg ',
  91. 'MPEG '=> 'video/mpeg ',
  92. 'Mpg' => 'video/mpeg ',
  93. 'Mpga' => 'audio/mpeg ',
  94. 'Ms' => 'application/x-troff-MS ',
  95. 'Msh' => 'model/mesh ',
  96. 'Mxu' => 'video/vnd. mpegurl ',
  97. 'NC '=> 'application/x-netcdf ',
  98. 'Oda '=> 'application/oda ',
  99. 'Ogc' => 'application/ogc ',
  100. 'Ogv' => 'video/ogv ',
  101. 'Pbm' => 'image/x-portable-bitmap ',
  102. 'Pct '=> 'image/pict ',
  103. 'Pdb' => 'chemical/x-pdb ',
  104. 'PDF '=> 'application/pdf ',
  105. 'Pgm '=> 'image/x-portable-graymap ',
  106. 'Pgn' => 'application/x-chess-pgn ',
  107. 'Pic '=> 'image/pict ',
  108. 'Pict' => 'image/pict ',
  109. 'PNG '=> 'image/png ',
  110. 'Pnm '=> 'image/x-portable-anymap ',
  111. 'Pnt '=> 'image/x-macpa ',
  112. 'Png' => 'image/x-macpa ',
  113. 'Ppm '=> 'image/x-portable-pixmap ',
  114. 'Ppt '=> 'application/vnd. ms-powerpoint ',
  115. 'PS '=> 'application/postscript ',
  116. 'Qt '=> 'video/quicktime ',
  117. 'Qti' => 'image/x-quicktime ',
  118. 'Qtif '=> 'image/x-quicktime ',
  119. 'A' => '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. 'Silo' => 'model/mesh ',
  133. 'Sit '=> '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' => 'audio/basic ',
  141. 'So' => '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. 'Text' => 'application/x-textinfo ',
  153. 'Textinfo' => 'application/x-textinfo ',
  154. 'Tif '=> 'image/tiff ',
  155. 'Tiff '=> 'image/tiff ',
  156. 'Tr' => 'application/x-troff ',
  157. 'Tsv' => 'text/tab-separated-values ',
  158. 'Txt '=> 'text/plain ',
  159. 'Ustar' => 'application/x-ustar ',
  160. 'Vcd' => 'application/x-cdlink ',
  161. 'Jpa' => 'model/jpa ',
  162. 'Vxml' => 'application/voicexml + XML ',
  163. 'Wav '=> 'audio/x-wav ',
  164. 'Wbmp '=> 'image/vnd. wap. wbmp ',
  165. 'Wbxml' => 'application/vnd. wap. wbxml ',
  166. 'Webm' => 'video/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' => 'model/jpa ',
  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, type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.