文件的MIME-TYPE

WBOY
發布: 2016-07-28 08:29:41
原創
1057 人瀏覽過

<code>header(<span>"content-type:text/html;charset=gbk"</span>);
<span>$mime</span> = <span>array</span>(
    <span>'gif'</span> => <span>'image/gif'</span>,
    <span>'jpg'</span> => <span>'image/jpeg'</span>,
    <span>'jpeg'</span> => <span>'image/jpeg'</span>,
    <span>'jpe'</span> => <span>'image/jpeg'</span>,
    <span>'bmp'</span> => <span>'image/bmp'</span>,
    <span>'png'</span> => <span>'image/png'</span>,
    <span>'tif'</span> => <span>'image/tiff'</span>,
    <span>'tiff'</span> => <span>'image/tiff'</span>,
    <span>'pict'</span> => <span>'image/x-pict'</span>,
    <span>'pic'</span> => <span>'image/x-pict'</span>,
    <span>'pct'</span> => <span>'image/x-pict'</span>,
    <span>'tif'</span> => <span>'image/tiff'</span>,
    <span>'tiff'</span> => <span>'image/tiff'</span>,
    <span>'psd'</span> => <span>'image/x-photoshop'</span>,

    <span>'swf'</span> => <span>'application/x-shockwave-flash'</span>,
    <span>'js'</span> => <span>'application/x-javascrīpt'</span>,
    <span>'pdf'</span> => <span>'application/pdf'</span>,
    <span>'ps'</span> => <span>'application/postscrīpt'</span>,
    <span>'eps'</span> => <span>'application/postscrīpt'</span>,
    <span>'ai'</span> => <span>'application/postscrīpt'</span>,
    <span>'wmf'</span> => <span>'application/x-msmetafile'</span>,

    <span>'css'</span> => <span>'text/css'</span>,
    <span>'htm'</span> => <span>'text/html'</span>,
    <span>'html'</span> => <span>'text/html'</span>,
    <span>'txt'</span> => <span>'text/plain'</span>,
    <span>'xml'</span> => <span>'text/xml'</span>,
    <span>'wml'</span> => <span>'text/wml'</span>,
    <span>'wbmp'</span> => <span>'image/vnd.wap.wbmp'</span>,

    <span>'mid'</span> => <span>'audio/midi'</span>,
    <span>'wav'</span> => <span>'audio/wav'</span>,
    <span>'mp3'</span> => <span>'audio/mpeg'</span>,
    <span>'mp2'</span> => <span>'audio/mpeg'</span>,

    <span>'avi'</span> => <span>'video/x-msvideo'</span>,
    <span>'mpeg'</span> => <span>'video/mpeg'</span>,
    <span>'mpg'</span> => <span>'video/mpeg'</span>,
    <span>'qt'</span> => <span>'video/quicktime'</span>,
    <span>'mov'</span> => <span>'video/quicktime'</span>,

    <span>'lha'</span> => <span>'application/x-lha'</span>,
    <span>'lzh'</span> => <span>'application/x-lha'</span>,
    <span>'z'</span> => <span>'application/x-compress'</span>,
    <span>'gtar'</span> => <span>'application/x-gtar'</span>,
    <span>'gz'</span> => <span>'application/x-gzip'</span>,
    <span>'gzip'</span> => <span>'application/x-gzip'</span>,
    <span>'tgz'</span> => <span>'application/x-gzip'</span>,
    <span>'tar'</span> => <span>'application/x-tar'</span>,
    <span>'bz2'</span> => <span>'application/bzip2'</span>,
    <span>'zip'</span> => <span>'application/zip'</span>,
    <span>'arj'</span> => <span>'application/x-arj'</span>,
    <span>'rar'</span> => <span>'application/x-rar-compressed'</span>,

    <span>'hqx'</span> => <span>'application/mac-binhex40'</span>,
    <span>'sit'</span> => <span>'application/x-stuffit'</span>,
    <span>'bin'</span> => <span>'application/x-macbinary'</span>,

    <span>'uu'</span> => <span>'text/x-uuencode'</span>,
    <span>'uue'</span> => <span>'text/x-uuencode'</span>,

    <span>'latex'</span>=> <span>'application/x-latex'</span>,
    <span>'ltx'</span> => <span>'application/x-latex'</span>,
    <span>'tcl'</span> => <span>'application/x-tcl'</span>,

    <span>'pgp'</span> => <span>'application/pgp'</span>,
    <span>'asc'</span> => <span>'application/pgp'</span>,
    <span>'exe'</span> => <span>'application/x-msdownload'</span>,
    <span>'doc'</span> => <span>'application/msword'</span>,
    <span>'rtf'</span> => <span>'application/rtf'</span>,
    <span>'xls'</span> => <span>'application/vnd.ms-excel'</span>,
    <span>'ppt'</span> => <span>'application/vnd.ms-powerpoint'</span>,
    <span>'mdb'</span> => <span>'application/x-msaccess'</span>,
    <span>'wri'</span> => <span>'application/x-mswrite'</span>,
);
<span>$url</span> = <span>'http://tp4.sinaimg.cn/1692980395/180/1298526784/0'</span>;
<span>//$url = 'http://www.baidu.com/';</span><span>$ch</span> = curl_init();
curl_setopt(<span>$ch</span>, CURLOPT_URL, <span>$url</span>);
curl_setopt(<span>$ch</span>, CURLOPT_USERAGENT, <span>$_SERVER</span>[<span>'HTTP_USER_AGENT'</span>]);
curl_setopt(<span>$ch</span>, CURLOPT_HEADER, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_NOBODY, <span>1</span>);
curl_setopt(<span>$ch</span>, CURLOPT_RETURNTRANSFER, <span>1</span>);
<span>$contents</span> = curl_exec(<span>$ch</span>);
curl_close(<span>$ch</span>);

<span>if</span>(preg_match(<span>'/Content-Type:\s+(.*?)(?:;|\s)/i'</span>,<span>$contents</span>,<span>$arr</span>)){
  <span>$mimestr</span> = strtolower(trim(<span>$arr</span>[<span>1</span>]));
  <span>$outkey</span> = array_keys(<span>$mime</span>,<span>$mimestr</span>);
  <span>echo</span><span>'文件类型是:'</span>.implode(<span>','</span>,<span>$outkey</span>) ;
}<span>else</span>{
  <span>echo</span><span>'没有匹配到类型'</span>;
}</code>
登入後複製
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介紹了 文件的MIME-TYPE,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

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