1. //定义编码
  2. header( 'Content-Type:text/html;charset=utf-8 ');
  3. //Atom
  4. header('Content-type: application/atom+xml');
  5. //CSS
  6. header('Content-type: text/css');
  7. //Javascript
  8. header('Content-type: text/javascript');
  9. //JPEG Image
  10. header('Content-type: image/jpeg');
  11. //JSON
  12. header('Content-type: application/json');
  13. //PDF
  14. header('Content-type: application/pdf');
  15. //RSS
  16. header('Content-Type: application/rss+xml; charset=ISO-8859-1');
  17. //Text (Plain)
  18. header('Content-type: text/plain');
  19. //XML
  20. header('Content-type: text/xml');
  21. // ok
  22. header('HTTP/1.1 200 OK');
  23. //设置一个404头:
  24. header('HTTP/1.1 404 Not Found');
  25. //设置地址被永久的重定向
  26. header('HTTP/1.1 301 Moved Permanently');
  27. //转到一个新地址
  28. header('Location: http://www.example.org/');
  29. //文件延迟转向:
  30. header('Refresh: 10; url=http://www.example.org/');
  31. print 'You will be redirected in 10 seconds';
  32. //当然,也可以使用html语法实现
  33. // <meta http-equiv="refresh" content="10;http://www.example.org/ />
  34. // override X-Powered-By: PHP:
  35. header('X-Powered-By: PHP/4.4.0');
  36. header('X-Powered-By: Brain/0.6b');
  37. //文档语言
  38. header('Content-language: en');
  39. //告诉浏览器最后一次修改时间
  40. $time = time() - 60; // or filemtime($fn), etc
  41. header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
  42. //告诉浏览器文档内容没有发生改变
  43. header('HTTP/1.1 304 Not Modified');
  44. //设置内容长度
  45. header('Content-Length: 1234');
  46. //设置为一个下载类型
  47. header('Content-Type: application/octet-stream');
  48. header('Content-Disposition: attachment; filename="example.zip"');
  49. header('Content-Transfer-Encoding: binary');
  50. // load the file to send:
  51. readfile('example.zip');
  52. // 对当前文档禁用缓存
  53. header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
  54. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  55. header('Pragma: no-cache');
  56. //设置内容类型:
  57. header('Content-Type: text/html; charset=iso-8859-1');
  58. header('Content-Type: text/html; charset=utf-8');
  59. header('Content-Type: text/plain'); //纯文本格式
  60. header('Content-Type: image/jpeg'); //JPG***
  61. header('Content-Type: application/zip'); // ZIP文件
  62. header('Content-Type: application/pdf'); // PDF文件
  63. header('Content-Type: audio/mpeg'); // 音频文件
  64. header('Content-Type: application/x-shockw**e-flash'); //Flash动画
  65. //显示登陆对话框
  66. header('HTTP/1.1 401 Unauthorized');
  67. header('WWW-Authenticate: Basic realm="Top Secret"');
  68. print 'Text that will be displayed if the user hits cancel or ';
  69. print 'enters wrong login data';

下载xlsx文件

    1. $filename = rtrim($_SERVER['DOCUMENT_ROOT'],'/').'/app/files/payment_status.csv';
    2. header('Content-Disposition: attachment; filename=payment_status.xlsx');
    3. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    4. header('Content-Length: ' . filesize($filename));
    5. header('Content-Transfer-Encoding: binary');
    6. header('Cache-Control: must-revalidate');
    7. header('Pragma: public');
    8. readfile($filename);

php header() 常用content-type的更多相关文章

  1. the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header

    the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header ...

  2. Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.

    Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不 ...

  3. 转载 SharePoint【Site Definition 系列】– 创建Content Type

    转载原地址:  http://www.cnblogs.com/wsdj-ITtech/archive/2012/09/01/2470274.html Sharepoint本身就是一个丰富的大容器,里面 ...

  4. Java之POI读取Excel的Package should contain a content type part [M1.13]] with root cause异常问题解决

    Java之POI读取Excel的Package should contain a content type part [M1.13]] with root cause异常问题解决 引言: 在Java中 ...

  5. 接入WxPusher微信推送服务出现错误:Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

    背景 使用WxPusher微信推送服务 ,可以及时的将服务的一些运行异常信息,发送到自己的微信上,方便了解服务的运行状态(PS:这个服务是免费的). 你可以在这里看到WxPusher微信推送服务的接入 ...

  6. Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.

    用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static ...

  7. SharePoint自动化系列——Add content type to list.

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...

  8. SharePoint自动化系列——Content Type相关timer jobs一键执行

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 背景: 在SharePoint Central Administration->Monito ...

  9. Springs Element 'beans' cannot have character [children], because the type's content type is element-only

    Springs Element 'beans' cannot have character [children], because the type's content type is element ...

  10. springboot 报错 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

    开始 controller 方法写的是 @RequestMapping( value = "/add", method = RequestMethod.POST ) public ...

随机推荐

  1. 《java编程思想》多态与接口

    向上转型 定义:把某个对象的引用视为对其基类类型的引用的做法被称为向上转型方法调用绑定 将一个方法调用同一个方法主体关联起来被称作绑定. 前期绑定:程序执行前进行的绑定叫做前期绑定,前期绑定也是jav ...

  2. [noip模拟]计蒜姬<BFS>

    Description 兔纸们有一个计蒜姬,奇怪的是,这个计蒜姬只有一个寄存器X.兔纸们每次可以把寄存器中的数字取出,进行如下四种运算的一种后,将结果放回寄存器中.1.X=X+X2.X=X-X3.X= ...

  3. Effective Java要点笔记

    第一章: 创建和销毁对象 类可以通过静态工厂方法来提供客户端,而不是通过构造器 优点: 自定义工厂名称,提高可读性 可以工厂里搞单例 控制实例类是哪种子类 总之是更加灵活,可读性更高 缺点: 有可能会 ...

  4. Python——图像手绘效果

    1.图像的RGB色彩模式 PIL PIL, Python Image Library PIL库是一个具有强大图像处理能力的第三方库 在命令行下的安装方法: pip install pillow fro ...

  5. 文件输入输出实例&Ptask的编写

    前言 最近在写Ptask,顺便了解了如何进行文件读入输出.而在Ptask中最重要,也是最最容易出bug的地方就是文件操作.那么如何进行文件输入输出,在程序中起到重要作用呢? 输入 首先为了保证可以在控 ...

  6. JQuery主要内容

    一.什么是JQuery jquery全称javaScript Query,是js的一个框架,本质上仍然是js 二.jQuery的特点 支持各种主流浏览器 使用特别简单 拥有丰富的插件和边界的插件扩展机 ...

  7. node.js 实现接口-操作文件进行用户增删改查

    首先安装npm,使用npm安装express npm install express -S /* * @Author: yinxin * @Date: 2020-03-27 10:18:41 * @L ...

  8. PTA数据结构与算法题目集(中文) 7-31

    PTA数据结构与算法题目集(中文)  7-31 7-31 笛卡尔树 (25 分)   笛卡尔树是一种特殊的二叉树,其结点包含两个关键字K1和K2.首先笛卡尔树是关于K1的二叉搜索树,即结点左子树的所有 ...

  9. Scratch 第1课 让小猫动起来

    素材下载 链接:https://pan.baidu.com/s/1qX0T2B_zczcLaCCpiRrsnA提取码:xfp8

  10. var、let和const的区别详解

      let 和 const 是 ECMAScript6 新推出的特性,其中 let 是能够替代 var 的"标准",所以我们探讨 var.let 和 const 的区别,首先应该知 ...