- //定义编码
- header( 'Content-Type:text/html;charset=utf-8 ');
- //Atom
- header('Content-type: application/atom+xml');
- //CSS
- header('Content-type: text/css');
- //Javascript
- header('Content-type: text/javascript');
- //JPEG Image
- header('Content-type: image/jpeg');
- //JSON
- header('Content-type: application/json');
- header('Content-type: application/pdf');
- //RSS
- header('Content-Type: application/rss+xml; charset=ISO-8859-1');
- //Text (Plain)
- header('Content-type: text/plain');
- //XML
- header('Content-type: text/xml');
- // ok
- header('HTTP/1.1 200 OK');
- //设置一个404头:
- header('HTTP/1.1 404 Not Found');
- //设置地址被永久的重定向
- header('HTTP/1.1 301 Moved Permanently');
- //转到一个新地址
- header('Location: http://www.example.org/');
- //文件延迟转向:
- header('Refresh: 10; url=http://www.example.org/');
- print 'You will be redirected in 10 seconds';
- //当然,也可以使用html语法实现
- // <meta http-equiv="refresh" content="10;http://www.example.org/ />
- // override X-Powered-By: PHP:
- header('X-Powered-By: PHP/4.4.0');
- header('X-Powered-By: Brain/0.6b');
- //文档语言
- header('Content-language: en');
- //告诉浏览器最后一次修改时间
- $time = time() - 60; // or filemtime($fn), etc
- header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
- //告诉浏览器文档内容没有发生改变
- header('HTTP/1.1 304 Not Modified');
- //设置内容长度
- header('Content-Length: 1234');
- //设置为一个下载类型
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename="example.zip"');
- header('Content-Transfer-Encoding: binary');
- // load the file to send:
- readfile('example.zip');
- // 对当前文档禁用缓存
- header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
- header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
- header('Pragma: no-cache');
- //设置内容类型:
- header('Content-Type: text/html; charset=iso-8859-1');
- header('Content-Type: text/html; charset=utf-8');
- header('Content-Type: text/plain'); //纯文本格式
- header('Content-Type: image/jpeg'); //JPG***
- header('Content-Type: application/zip'); // ZIP文件
- header('Content-Type: application/pdf'); // PDF文件
- header('Content-Type: audio/mpeg'); // 音频文件
- header('Content-Type: application/x-shockw**e-flash'); //Flash动画
- //显示登陆对话框
- header('HTTP/1.1 401 Unauthorized');
- header('WWW-Authenticate: Basic realm="Top Secret"');
- print 'Text that will be displayed if the user hits cancel or ';
- print 'enters wrong login data';
1 Content-type 的说明 2 3 $mimetypes = array( 4 'ez' => 'application/andrew-inset', 5 'hqx' => 'application/mac-binhex40', 6 'cpt' => 'application/mac-compactpro', 7 'doc' => 'application/msword', 8 'bin' => 'application/octet-stream', 9 'dms' => 'application/octet-stream', 10 'lha' => 'application/octet-stream', 11 'lzh' => 'application/octet-stream', 12 'exe' => 'application/octet-stream', 13 'class' => 'application/octet-stream', 14 'so' => 'application/octet-stream', 15 'dll' => 'application/octet-stream', 16 'oda' => 'application/oda', 17 'pdf' => 'application/pdf', 18 'ai' => 'application/postscript', 19 'eps' => 'application/postscript', 20 'ps' => 'application/postscript', 21 'smi' => 'application/smil', 22 'smil' => 'application/smil', 23 24 'mif' => 'application/vnd.mif', 25 'xls' => 'application/vnd.ms-excel', 26 'ppt' => 'application/vnd.ms-powerpoint', 27 'wbxml' => 'application/vnd.wap.wbxml', 28 'wmlc' => 'application/vnd.wap.wmlc', 29 'wmlsc' => 'application/vnd.wap.wmlscriptc', 30 'bcpio' => 'application/x-bcpio', 31 'vcd' => 'application/x-cdlink', 32 'pgn' => 'application/x-chess-pgn', 33 'cpio' => 'application/x-cpio', 34 'csh' => 'application/x-csh', 35 36 'dcr' => 'application/x-director', 37 'dir' => 'application/x-director', 38 'dxr' => 'application/x-director', 39 'dvi' => 'application/x-dvi', 40 'spl' => 'application/x-futuresplash', 41 'gtar' => 'application/x-gtar', 42 'hdf' => 'application/x-hdf', 43 'js' => 'application/x-javascript', 44 'skp' => 'application/x-koan', 45 'skd' => 'application/x-koan', 46 'skt' => 'application/x-koan', 47 'skm' => 'application/x-koan', 48 'latex' => 'application/x-latex', 49 'nc' => 'application/x-netcdf', 50 'cdf' => 'application/x-netcdf', 51 'sh' => 'application/x-sh', 52 'shar' => 'application/x-shar', 53 'swf' => 'application/x-shockwave-flash', 54 'sit' => 'application/x-stuffit', 55 'sv4cpio' => 'application/x-sv4cpio', 56 'sv4crc' => 'application/x-sv4crc', 57 'tar' => 'application/x-tar', 58 'tcl' => 'application/x-tcl', 59 'tex' => 'application/x-tex', 60 'texinfo' => 'application/x-texinfo', 61 'texi' => 'application/x-texinfo', 62 't' => 'application/x-troff', 63 'tr' => 'application/x-troff', 64 'roff' => 'application/x-troff', 65 'man' => 'application/x-troff-man', 66 'me' => 'application/x-troff-me', 67 'ms' => 'application/x-troff-ms', 68 'ustar' => 'application/x-ustar', 69 'src' => 'application/x-wais-source', 70 'xhtml' => 'application/xhtml+xml', 71 'xht' => 'application/xhtml+xml', 72 'zip' => 'application/zip', 73 'au' => 'audio/basic', 74 'snd' => 'audio/basic', 75 'mid' => 'audio/midi', 76 'midi' => 'audio/midi', 77 'kar' => 'audio/midi', 78 'mpga' => 'audio/mpeg', 79 'mp2' => 'audio/mpeg', 80 'mp3' => 'audio/mpeg', 81 'aif' => 'audio/x-aiff', 82 'aiff' => 'audio/x-aiff', 83 'aifc' => 'audio/x-aiff', 84 'm3u' => 'audio/x-mpegurl', 85 'ram' => 'audio/x-pn-realaudio', 86 'rm' => 'audio/x-pn-realaudio', 87 'rpm' => 'audio/x-pn-realaudio-plugin', 88 'ra' => 'audio/x-realaudio', 89 'wav' => 'audio/x-wav', 90 'pdb' => 'chemical/x-pdb', 91 'xyz' => 'chemical/x-xyz', 92 'bmp' => 'image/bmp', 93 'gif' => 'image/gif', 94 'ief' => 'image/ief', 95 'jpeg' => 'image/jpeg', 96 'jpg' => 'image/jpeg', 97 'jpe' => 'image/jpeg', 98 'png' => 'image/png', 99 'tiff' => 'image/tiff', 100 'tif' => 'image/tiff', 101 'djvu' => 'image/vnd.djvu', 102 'djv' => 'image/vnd.djvu', 103 'wbmp' => 'image/vnd.wap.wbmp', 104 'ras' => 'image/x-cmu-raster', 105 'pnm' => 'image/x-portable-anymap', 106 'pbm' => 'image/x-portable-bitmap', 107 'pgm' => 'image/x-portable-graymap', 108 'ppm' => 'image/x-portable-pixmap', 109 'rgb' => 'image/x-rgb', 110 'xbm' => 'image/x-xbitmap', 111 'xpm' => 'image/x-xpixmap', 112 'xwd' => 'image/x-xwindowdump', 113 'igs' => 'model/iges', 114 'iges' => 'model/iges', 115 'msh' => 'model/mesh', 116 'mesh' => 'model/mesh', 117 'silo' => 'model/mesh', 118 'wrl' => 'model/vrml', 119 'vrml' => 'model/vrml', 120 'css' => 'text/css', 121 'html' => 'text/html', 122 'htm' => 'text/html', 123 'asc' => 'text/plain', 124 'txt' => 'text/plain', 125 'rtx' => 'text/richtext', 126 'rtf' => 'text/rtf', 127 'sgml' => 'text/sgml', 128 'sgm' => 'text/sgml', 129 'tsv' => 'text/tab-separated-values', 130 'wml' => 'text/vnd.wap.wml', 131 'wmls' => 'text/vnd.wap.wmlscript', 132 'etx' => 'text/x-setext', 133 'xsl' => 'text/xml', 134 'xml' => 'text/xml', 135 'mpeg' => 'video/mpeg', 136 137 'mpg' => 'video/mpeg', 138 'mpe' => 'video/mpeg', 139 'qt' => 'video/quicktime', 140 'mov' => 'video/quicktime', 141 'mxu' => 'video/vnd.mpegurl', 142 'avi' => 'video/x-msvideo', 143 'movie' => 'video/x-sgi-movie', 144 'ice' => 'x-conference/x-cooltalk', 145 );
The following table documents the HTTP MIME types that are available when working with Office 2007 documents:
Ext |
MIME Type |
.doc |
application/msword |
.dot |
application/msword |
.docx |
application/vnd.openxmlformats-officedocument.wordprocessingml.document |
.dotx |
application/vnd.openxmlformats-officedocument.wordprocessingml.template |
.docm |
application/vnd.ms-word.document.macroEnabled.12 |
.dotm |
application/vnd.ms-word.template.macroEnabled.12 |
.xls |
application/vnd.ms-excel |
.xlt |
application/vnd.ms-excel |
.xla |
application/vnd.ms-excel |
.xlsx |
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
.xltx |
application/vnd.openxmlformats-officedocument.spreadsheetml.template |
.xlsm |
application/vnd.ms-excel.sheet.macroEnabled.12 |
.xltm |
application/vnd.ms-excel.template.macroEnabled.12 |
.xlam |
application/vnd.ms-excel.addin.macroEnabled.12 |
.xlsb |
application/vnd.ms-excel.sheet.binary.macroEnabled.12 |
.ppt |
application/vnd.ms-powerpoint |
.pot |
application/vnd.ms-powerpoint |
.pps |
application/vnd.ms-powerpoint |
.ppa |
application/vnd.ms-powerpoint |
.pptx |
application/vnd.openxmlformats-officedocument.presentationml.presentation |
.potx |
application/vnd.openxmlformats-officedocument.presentationml.template |
.ppsx |
application/vnd.openxmlformats-officedocument.presentationml.slideshow |
.ppam |
application/vnd.ms-powerpoint.addin.macroEnabled.12 |
.pptm |
application/vnd.ms-powerpoint.presentation.macroEnabled.12 |
.potm |
application/vnd.ms-powerpoint.presentation.macroEnabled.12 |
.ppsm |
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 |