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. NodeMCU入坑指南-低成本打造零舍友闻风丧胆WiFi断网神器

    前言 最近对IoT方面比较感兴趣,所以在某宝上入手了一块NodeMCU的开发板,至于为什么我选择这块开发板呢?嘿嘿,当然是因为便宜啊

  2. vi文本编辑器的学习

    vi文本编辑器的启动与退出 启动:快捷键Ctrl+Alt+t进入终端, 在系统提示符($或#)的提示下,输入vi <文件名称>,可以自动载入你要编辑的文件或者新建一个文件. 退出:在指令模 ...

  3. CodeForces 277A 红娘问题(并查子集)

    题目链接 思路如下 这题可以普通的并查集来做,我们把每个人认识的红娘,放到一个同一个集合里面,然后通过 for循环 遍历出现过的编号,看总共有几个集合,当集合的个数大于1的时候,需要的话费rmb的数量 ...

  4. python爬虫之requests的高级使用

    1.requests能上传文件 # 导入requests模块 import requests # 定义一个dict files = {'file': open('D:/360Downloads/1.t ...

  5. mysql中关于exists的深入讲解

    mysql中关于exists的讲解 我认为exists语法是mysql中一个很强大的工具,可以简单地实现某些复杂的数据处理. 下面我谈谈与exists有关的三个方面. all 与 any 首先,看到了 ...

  6. PTA数据结构与算法题目集(中文) 7-37 模拟EXCEL排序 (25 分)

    PTA数据结构与算法题目集(中文)  7-37 模拟EXCEL排序 (25 分) 7-37 模拟EXCEL排序 (25 分)   Excel可以对一组纪录按任意指定列排序.现请编写程序实现类似功能. ...

  7. P3381 【模板】最小费用最大流 题解

    CSDN同步 原题链接 前置知识: 从三种算法剖析网络流本质 简要题意: 给定网络图,求图的最大流,以及流量为最大流时的最小费用. 现在假设你们看了那篇网络流博客之后,所有人都会了 \(\text{E ...

  8. 使用Azure Rest API获得Access Token介绍

    背景 本文主要介绍如何获取如何获取Azure Rest API的访问token,所采用的是v2.0版本的Microsoft标识平台,关于1.0和2.0的区别可以参考 https://docs.azur ...

  9. 阿里云服务器扩展分区和文件系统_Linux数据盘

    官方文档永远是最好的 https://help.aliyun.com/document_detail/25452.html?spm=a2c4g.11186623.6.786.5fde4656Ln6AO ...

  10. C语言数据结构队列

    #include<stdio.h>#include<stdlib.h>struct Node { int data;  Node *next;};struct Queue { ...