PHP Gets the MIME type type of the file

Source: Internet
Author: User
Tags xslt gtar
  1. /**
  2. * Get MIME type type of file
  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. ' avi ' = ' 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-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 ' = ' Text/calendar ',
  58. ' Ief ' = ' image/ief ',
  59. ' IFB ' = ' Text/calendar ',
  60. ' IGEs ' = ' model/iges ',
  61. ' IGs ' = ' 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. ' M4V ' = ' video/x-m4v ',
  77. ' Mac ' = ' Image/x-macpaint ',
  78. ' Man ' = ' Application/x-troff-man ',
  79. ' MathML ' = ' application/mathml+xml ',
  80. ' Me ' = ' application/x-troff-me ',
  81. ' Mesh ' = ' model/mesh ',
  82. ' Mid ' = ' Audio/midi ',
  83. ' midi ' = ' Audio/midi ',
  84. ' MIF ' = ' application/vnd.mif ',
  85. ' mov ' = ' video/quicktime ',
  86. ' Movie ' = ' Video/x-sgi-movie ',
  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. ' Ogg ' = ' application/ogg ',
  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-macpaint ',
  112. ' Pntg ' = ' image/x-macpaint ',
  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. ' 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. ' 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. ' Texi ' = ' application/x-texinfo ',
  153. ' Texinfo ' = ' application/x-texinfo ',
  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. ' VRML ' = ' model/vrml ',
  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/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. }
Copy Code
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.