mimetypes.class.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * 获得文件的mime type类型
  4. * @author xiaobing.meng
  5. *
  6. */
  7. class MimeTypes {
  8. public static $mime_types = array (
  9. 'apk' => 'application/vnd.android.package-archive',
  10. '3gp' => 'video/3gpp', 'ai' => 'application/postscript',
  11. 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff',
  12. 'aiff' => 'audio/x-aiff', 'asc' => 'text/plain',
  13. 'atom' => 'application/atom+xml', 'au' => 'audio/basic',
  14. 'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio',
  15. 'bin' => 'application/octet-stream', 'bmp' => 'image/bmp',
  16. 'cdf' => 'application/x-netcdf', 'cgm' => 'image/cgm',
  17. 'class' => 'application/octet-stream',
  18. 'cpio' => 'application/x-cpio',
  19. 'cpt' => 'application/mac-compactpro',
  20. 'csh' => 'application/x-csh', 'css' => 'text/css',
  21. 'dcr' => 'application/x-director', 'dif' => 'video/x-dv',
  22. 'dir' => 'application/x-director', 'djv' => 'image/vnd.djvu',
  23. 'djvu' => 'image/vnd.djvu',
  24. 'dll' => 'application/octet-stream',
  25. 'dmg' => 'application/octet-stream',
  26. 'dms' => 'application/octet-stream',
  27. 'doc' => 'application/msword', 'dtd' => 'application/xml-dtd',
  28. 'dv' => 'video/x-dv', 'dvi' => 'application/x-dvi',
  29. 'dxr' => 'application/x-director',
  30. 'eps' => 'application/postscript', 'etx' => 'text/x-setext',
  31. 'exe' => 'application/octet-stream',
  32. 'ez' => 'application/andrew-inset', 'flv' => 'video/x-flv',
  33. 'gif' => 'image/gif', 'gram' => 'application/srgs',
  34. 'grxml' => 'application/srgs+xml',
  35. 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip',
  36. 'hdf' => 'application/x-hdf',
  37. 'hqx' => 'application/mac-binhex40', 'htm' => 'text/html',
  38. 'html' => 'text/html', 'ice' => 'x-conference/x-cooltalk',
  39. 'ico' => 'image/x-icon', 'ics' => 'text/calendar',
  40. 'ief' => 'image/ief', 'ifb' => 'text/calendar',
  41. 'iges' => 'model/iges', 'igs' => 'model/iges',
  42. 'jnlp' => 'application/x-java-jnlp-file', 'jp2' => 'image/jp2',
  43. 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg',
  44. 'jpg' => 'image/jpeg', 'js' => 'application/x-javascript',
  45. 'kar' => 'audio/midi', 'latex' => 'application/x-latex',
  46. 'lha' => 'application/octet-stream',
  47. 'lzh' => 'application/octet-stream',
  48. 'm3u' => 'audio/x-mpegurl', 'm4a' => 'audio/mp4a-latm',
  49. 'm4p' => 'audio/mp4a-latm', 'm4u' => 'video/vnd.mpegurl',
  50. 'm4v' => 'video/x-m4v', 'mac' => 'image/x-macpaint',
  51. 'man' => 'application/x-troff-man',
  52. 'mathml' => 'application/mathml+xml',
  53. 'me' => 'application/x-troff-me', 'mesh' => 'model/mesh',
  54. 'mid' => 'audio/midi', 'midi' => 'audio/midi',
  55. 'mif' => 'application/vnd.mif', 'mov' => 'video/quicktime',
  56. 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg',
  57. 'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4',
  58. 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg',
  59. 'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg',
  60. 'ms' => 'application/x-troff-ms', 'msh' => 'model/mesh',
  61. 'mxu' => 'video/vnd.mpegurl', 'nc' => 'application/x-netcdf',
  62. 'oda' => 'application/oda', 'ogg' => 'application/ogg',
  63. 'ogv' => 'video/ogv', 'pbm' => 'image/x-portable-bitmap',
  64. 'pct' => 'image/pict', 'pdb' => 'chemical/x-pdb',
  65. 'pdf' => 'application/pdf',
  66. 'pgm' => 'image/x-portable-graymap',
  67. 'pgn' => 'application/x-chess-pgn', 'pic' => 'image/pict',
  68. 'pict' => 'image/pict', 'png' => 'image/png',
  69. 'pnm' => 'image/x-portable-anymap',
  70. 'pnt' => 'image/x-macpaint', 'pntg' => 'image/x-macpaint',
  71. 'ppm' => 'image/x-portable-pixmap',
  72. 'ppt' => 'application/vnd.ms-powerpoint',
  73. 'ps' => 'application/postscript', 'qt' => 'video/quicktime',
  74. 'qti' => 'image/x-quicktime', 'qtif' => 'image/x-quicktime',
  75. 'ra' => 'audio/x-pn-realaudio',
  76. 'ram' => 'audio/x-pn-realaudio', 'ras' => 'image/x-cmu-raster',
  77. 'rdf' => 'application/rdf+xml', 'rgb' => 'image/x-rgb',
  78. 'rm' => 'application/vnd.rn-realmedia',
  79. 'roff' => 'application/x-troff', 'rtf' => 'text/rtf',
  80. 'rtx' => 'text/richtext', 'sgm' => 'text/sgml',
  81. 'sgml' => 'text/sgml', 'sh' => 'application/x-sh',
  82. 'shar' => 'application/x-shar', 'silo' => 'model/mesh',
  83. 'sit' => 'application/x-stuffit',
  84. 'skd' => 'application/x-koan', 'skm' => 'application/x-koan',
  85. 'skp' => 'application/x-koan', 'skt' => 'application/x-koan',
  86. 'smi' => 'application/smil', 'smil' => 'application/smil',
  87. 'snd' => 'audio/basic', 'so' => 'application/octet-stream',
  88. 'spl' => 'application/x-futuresplash',
  89. 'src' => 'application/x-wais-source',
  90. 'sv4cpio' => 'application/x-sv4cpio',
  91. 'sv4crc' => 'application/x-sv4crc', 'svg' => 'image/svg+xml',
  92. 'swf' => 'application/x-shockwave-flash',
  93. 't' => 'application/x-troff', 'tar' => 'application/x-tar',
  94. 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex',
  95. 'texi' => 'application/x-texinfo',
  96. 'texinfo' => 'application/x-texinfo', 'tif' => 'image/tiff',
  97. 'tiff' => 'image/tiff', 'tr' => 'application/x-troff',
  98. 'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain',
  99. 'ustar' => 'application/x-ustar',
  100. 'vcd' => 'application/x-cdlink', 'vrml' => 'model/vrml',
  101. 'vxml' => 'application/voicexml+xml', 'wav' => 'audio/x-wav',
  102. 'wbmp' => 'image/vnd.wap.wbmp',
  103. 'wbxml' => 'application/vnd.wap.wbxml', 'webm' => 'video/webm',
  104. 'wml' => 'text/vnd.wap.wml',
  105. 'wmlc' => 'application/vnd.wap.wmlc',
  106. 'wmls' => 'text/vnd.wap.wmlscript',
  107. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  108. 'wmv' => 'video/x-ms-wmv', 'wrl' => 'model/vrml',
  109. 'xbm' => 'image/x-xbitmap', 'xht' => 'application/xhtml+xml',
  110. 'xhtml' => 'application/xhtml+xml',
  111. 'xls' => 'application/vnd.ms-excel',
  112. 'xml' => 'application/xml', 'xpm' => 'image/x-xpixmap',
  113. 'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml',
  114. 'xul' => 'application/vnd.mozilla.xul+xml',
  115. 'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz',
  116. 'zip' => 'application/zip' );
  117. public static function get_mimetype($ext) {
  118. return (isset ( self::$mime_types [$ext] ) ? self::$mime_types [$ext] : 'application/octet-stream');
  119. }
  120. }