php header() 常用content-type
- //定义编码
- 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';
下载xlsx文件
- $filename = rtrim($_SERVER['DOCUMENT_ROOT'],'/').'/app/files/payment_status.csv';
- header('Content-Disposition: attachment; filename=payment_status.xlsx');
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Length: ' . filesize($filename));
- header('Content-Transfer-Encoding: binary');
- header('Cache-Control: must-revalidate');
- header('Pragma: public');
- readfile($filename);
php header() 常用content-type的更多相关文章
- 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 ...
- Jsoup问题---获取http协议请求失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
Jsoup问题---获取http协议请求失败 1.问题:用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不 ...
- 转载 SharePoint【Site Definition 系列】– 创建Content Type
转载原地址: http://www.cnblogs.com/wsdj-ITtech/archive/2012/09/01/2470274.html Sharepoint本身就是一个丰富的大容器,里面 ...
- 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中 ...
- 接入WxPusher微信推送服务出现错误:Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
背景 使用WxPusher微信推送服务 ,可以及时的将服务的一些运行异常信息,发送到自己的微信上,方便了解服务的运行状态(PS:这个服务是免费的). 你可以在这里看到WxPusher微信推送服务的接入 ...
- Jsoup获取部分页面数据失败 org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml.
用Jsoup在获取一些网站的数据时,起初获取很顺利,但是在访问某浪的数据是Jsoup报错,应该是请求头里面的请求类型(ContextType)不符合要求. 请求代码如下: private static ...
- SharePoint自动化系列——Add content type to list.
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 将创建好的content type(若是跨web application需要事先publish c ...
- SharePoint自动化系列——Content Type相关timer jobs一键执行
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 背景: 在SharePoint Central Administration->Monito ...
- 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 ...
- springboot 报错 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
开始 controller 方法写的是 @RequestMapping( value = "/add", method = RequestMethod.POST ) public ...
随机推荐
- 《java编程思想》多态与接口
向上转型 定义:把某个对象的引用视为对其基类类型的引用的做法被称为向上转型方法调用绑定 将一个方法调用同一个方法主体关联起来被称作绑定. 前期绑定:程序执行前进行的绑定叫做前期绑定,前期绑定也是jav ...
- [noip模拟]计蒜姬<BFS>
Description 兔纸们有一个计蒜姬,奇怪的是,这个计蒜姬只有一个寄存器X.兔纸们每次可以把寄存器中的数字取出,进行如下四种运算的一种后,将结果放回寄存器中.1.X=X+X2.X=X-X3.X= ...
- Effective Java要点笔记
第一章: 创建和销毁对象 类可以通过静态工厂方法来提供客户端,而不是通过构造器 优点: 自定义工厂名称,提高可读性 可以工厂里搞单例 控制实例类是哪种子类 总之是更加灵活,可读性更高 缺点: 有可能会 ...
- Python——图像手绘效果
1.图像的RGB色彩模式 PIL PIL, Python Image Library PIL库是一个具有强大图像处理能力的第三方库 在命令行下的安装方法: pip install pillow fro ...
- 文件输入输出实例&Ptask的编写
前言 最近在写Ptask,顺便了解了如何进行文件读入输出.而在Ptask中最重要,也是最最容易出bug的地方就是文件操作.那么如何进行文件输入输出,在程序中起到重要作用呢? 输入 首先为了保证可以在控 ...
- JQuery主要内容
一.什么是JQuery jquery全称javaScript Query,是js的一个框架,本质上仍然是js 二.jQuery的特点 支持各种主流浏览器 使用特别简单 拥有丰富的插件和边界的插件扩展机 ...
- node.js 实现接口-操作文件进行用户增删改查
首先安装npm,使用npm安装express npm install express -S /* * @Author: yinxin * @Date: 2020-03-27 10:18:41 * @L ...
- PTA数据结构与算法题目集(中文) 7-31
PTA数据结构与算法题目集(中文) 7-31 7-31 笛卡尔树 (25 分) 笛卡尔树是一种特殊的二叉树,其结点包含两个关键字K1和K2.首先笛卡尔树是关于K1的二叉搜索树,即结点左子树的所有 ...
- Scratch 第1课 让小猫动起来
素材下载 链接:https://pan.baidu.com/s/1qX0T2B_zczcLaCCpiRrsnA提取码:xfp8
- var、let和const的区别详解
let 和 const 是 ECMAScript6 新推出的特性,其中 let 是能够替代 var 的"标准",所以我们探讨 var.let 和 const 的区别,首先应该知 ...