Heim > php教程 > php手册 > Hauptteil

根据文件后缀获取mime类型

WBOY
Freigeben: 2016-06-07 11:45:45
Original
1438 Leute haben es durchsucht

/**<br>  * 根据文件后缀获取mime类型<br>  * @param  string $ext 文件后缀<br>  * @return string      mime类型<br>  */<br> function get_mime_type($ext){<br>     static $mime_types = array (<br>         'apk'     => 'application/vnd.android.package-archive',<br>         '3gp'     => 'video/3gpp', <br>         'ai'      => 'application/postscript', <br>         'aif'     => 'audio/x-aiff', <br>         'aifc'    => 'audio/x-aiff', <br>         'aiff'    => 'audio/x-aiff', <br>         'asc'     => 'text/plain', <br>         'atom'    => 'application/atom+xml', <br>         'au'      => 'audio/basic', <br>         'avi'     => 'video/x-msvideo', <br>         'bcpio'   => 'application/x-bcpio', <br>         'bin'     => 'application/octet-stream', <br>         'bmp'     => 'image/bmp', <br>         'cdf'     => 'application/x-netcdf', <br>         'cgm'     => 'image/cgm', <br>         'class'   => 'application/octet-stream', <br>         'cpio'    => 'application/x-cpio', <br>         'cpt'     => 'application/mac-compactpro', <br>         'csh'     => 'application/x-csh', <br>         'css'     => 'text/css', <br>         'dcr'     => 'application/x-director', <br>         'dif'     => 'video/x-dv', <br>         'dir'     => 'application/x-director', <br>         'djv'     => 'image/vnd.djvu', <br>         'djvu'    => 'image/vnd.djvu', <br>         'dll'     => 'application/octet-stream', <br>         'dmg'     => 'application/octet-stream', <br>         'dms'     => 'application/octet-stream', <br>         'doc'     => 'application/msword', <br>         'dtd'     => 'application/xml-dtd', <br>         'dv'      => 'video/x-dv', <br>         'dvi'     => 'application/x-dvi', <br>         'dxr'     => 'application/x-director', <br>         'eps'     => 'application/postscript', <br>         'etx'     => 'text/x-setext', <br>         'exe'     => 'application/octet-stream', <br>         'ez'      => 'application/andrew-inset', <br>         'flv'     => 'video/x-flv', <br>         'gif'     => 'image/gif', <br>         'gram'    => 'application/srgs', <br>         'grxml'   => 'application/srgs+xml', <br>         'gtar'    => 'application/x-gtar', <br>         'gz'      => 'application/x-gzip', <br>         'hdf'     => 'application/x-hdf', <br>         'hqx'     => 'application/mac-binhex40', <br>         'htm'     => 'text/html', <br>         'html'    => 'text/html', <br>         'ice'     => 'x-conference/x-cooltalk', <br>         'ico'     => 'image/x-icon', <br>         'ics'     => 'text/calendar', <br>         'ief'     => 'image/ief', <br>         'ifb'     => 'text/calendar', <br>         'iges'    => 'model/iges', <br>         'igs'     => 'model/iges', <br>         'jnlp'    => 'application/x-java-jnlp-file', <br>         'jp2'     => 'image/jp2', <br>         'jpe'     => 'image/jpeg', <br>         'jpeg'    => 'image/jpeg', <br>         'jpg'     => 'image/jpeg', <br>         'js'      => 'application/x-javascript', <br>         'kar'     => 'audio/midi', <br>         'latex'   => 'application/x-latex', <br>         'lha'     => 'application/octet-stream', <br>         'lzh'     => 'application/octet-stream', <br>         'm3u'     => 'audio/x-mpegurl', <br>         'm4a'     => 'audio/mp4a-latm', <br>         'm4p'     => 'audio/mp4a-latm', <br>         'm4u'     => 'video/vnd.mpegurl', <br>         'm4v'     => 'video/x-m4v', <br>         'mac'     => 'image/x-macpaint', <br>         'man'     => 'application/x-troff-man', <br>         'mathml'  => 'application/mathml+xml', <br>         'me'      => 'application/x-troff-me', <br>         'mesh'    => 'model/mesh', <br>         'mid'     => 'audio/midi', <br>         'midi'    => 'audio/midi', <br>         'mif'     => 'application/vnd.mif', <br>         'mov'     => 'video/quicktime', <br>         'movie'   => 'video/x-sgi-movie', <br>         'mp2'     => 'audio/mpeg', <br>         'mp3'     => 'audio/mpeg', <br>         'mp4'     => 'video/mp4', <br>         'mpe'     => 'video/mpeg', <br>         'mpeg'    => 'video/mpeg', <br>         'mpg'     => 'video/mpeg', <br>         'mpga'    => 'audio/mpeg', <br>         'ms'      => 'application/x-troff-ms', <br>         'msh'     => 'model/mesh', <br>         'mxu'     => 'video/vnd.mpegurl', <br>         'nc'      => 'application/x-netcdf', <br>         'oda'     => 'application/oda', <br>         'ogg'     => 'application/ogg', <br>         'ogv'     => 'video/ogv', <br>         'pbm'     => 'image/x-portable-bitmap', <br>         'pct'     => 'image/pict', <br>         'pdb'     => 'chemical/x-pdb', <br>         'pdf'     => 'application/pdf', <br>         'pgm'     => 'image/x-portable-graymap', <br>         'pgn'     => 'application/x-chess-pgn', <br>         'pic'     => 'image/pict', <br>         'pict'    => 'image/pict', <br>         'png'     => 'image/png', <br>         'pnm'     => 'image/x-portable-anymap', <br>         'pnt'     => 'image/x-macpaint', <br>         'pntg'    => 'image/x-macpaint', <br>         'ppm'     => 'image/x-portable-pixmap', <br>         'ppt'     => 'application/vnd.ms-powerpoint', <br>         'ps'      => 'application/postscript', <br>         'qt'      => 'video/quicktime', <br>         'qti'     => 'image/x-quicktime', <br>         'qtif'    => 'image/x-quicktime', <br>         'ra'      => 'audio/x-pn-realaudio', <br>         'ram'     => 'audio/x-pn-realaudio', <br>         'ras'     => 'image/x-cmu-raster', <br>         'rdf'     => 'application/rdf+xml', <br>         'rgb'     => 'image/x-rgb', <br>         'rm'      => 'application/vnd.rn-realmedia', <br>         'roff'    => 'application/x-troff', <br>         'rtf'     => 'text/rtf', <br>         'rtx'     => 'text/richtext', <br>         'sgm'     => 'text/sgml', <br>         'sgml'    => 'text/sgml', <br>         'sh'      => 'application/x-sh', <br>         'shar'    => 'application/x-shar', <br>         'silo'    => 'model/mesh', <br>         'sit'     => 'application/x-stuffit', <br>         'skd'     => 'application/x-koan', <br>         'skm'     => 'application/x-koan', <br>         'skp'     => 'application/x-koan', <br>         'skt'     => 'application/x-koan', <br>         'smi'     => 'application/smil', <br>         'smil'    => 'application/smil', <br>         'snd'     => 'audio/basic', <br>         'so'      => 'application/octet-stream', <br>         'spl'     => 'application/x-futuresplash', <br>         'src'     => 'application/x-wais-source', <br>         'sv4cpio' => 'application/x-sv4cpio', <br>         'sv4crc'  => 'application/x-sv4crc', <br>         'svg'     => 'image/svg+xml', <br>         'swf'     => 'application/x-shockwave-flash', <br>         't'       => 'application/x-troff', <br>         'tar'     => 'application/x-tar', <br>         'tcl'     => 'application/x-tcl', <br>         'tex'     => 'application/x-tex', <br>         'texi'    => 'application/x-texinfo', <br>         'texinfo' => 'application/x-texinfo', <br>         'tif'     => 'image/tiff', <br>         'tiff'    => 'image/tiff', <br>         'tr'      => 'application/x-troff', <br>         'tsv'     => 'text/tab-separated-values', <br>         'txt'     => 'text/plain', <br>         'ustar'   => 'application/x-ustar', <br>         'vcd'     => 'application/x-cdlink', <br>         'vrml'    => 'model/vrml', <br>         'vxml'    => 'application/voicexml+xml', <br>         'wav'     => 'audio/x-wav', <br>         'wbmp'    => 'image/vnd.wap.wbmp', <br>         'wbxml'   => 'application/vnd.wap.wbxml', <br>         'webm'    => 'video/webm', <br>         'wml'     => 'text/vnd.wap.wml', <br>         'wmlc'    => 'application/vnd.wap.wmlc', <br>         'wmls'    => 'text/vnd.wap.wmlscript', <br>         'wmlsc'   => 'application/vnd.wap.wmlscriptc', <br>         'wmv'     => 'video/x-ms-wmv', <br>         'wrl'     => 'model/vrml', <br>         'xbm'     => 'image/x-xbitmap', <br>         'xht'     => 'application/xhtml+xml', <br>         'xhtml'   => 'application/xhtml+xml', <br>         'xls'     => 'application/vnd.ms-excel', <br>         'xml'     => 'application/xml', <br>         'xpm'     => 'image/x-xpixmap', <br>         'xsl'     => 'application/xml', <br>         'xslt'    => 'application/xslt+xml', <br>         'xul'     => 'application/vnd.mozilla.xul+xml', <br>         'xwd'     => 'image/x-xwindowdump', <br>         'xyz'     => 'chemical/x-xyz', <br>         'zip'     => 'application/zip' <br>     );<br>     <br>     return isset($mime_types[$ext]) ? $mime_types[$ext] : 'application/octet-stream';<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!