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 ...
随机推荐
- NodeMCU入坑指南-低成本打造零舍友闻风丧胆WiFi断网神器
前言 最近对IoT方面比较感兴趣,所以在某宝上入手了一块NodeMCU的开发板,至于为什么我选择这块开发板呢?嘿嘿,当然是因为便宜啊
- vi文本编辑器的学习
vi文本编辑器的启动与退出 启动:快捷键Ctrl+Alt+t进入终端, 在系统提示符($或#)的提示下,输入vi <文件名称>,可以自动载入你要编辑的文件或者新建一个文件. 退出:在指令模 ...
- CodeForces 277A 红娘问题(并查子集)
题目链接 思路如下 这题可以普通的并查集来做,我们把每个人认识的红娘,放到一个同一个集合里面,然后通过 for循环 遍历出现过的编号,看总共有几个集合,当集合的个数大于1的时候,需要的话费rmb的数量 ...
- python爬虫之requests的高级使用
1.requests能上传文件 # 导入requests模块 import requests # 定义一个dict files = {'file': open('D:/360Downloads/1.t ...
- mysql中关于exists的深入讲解
mysql中关于exists的讲解 我认为exists语法是mysql中一个很强大的工具,可以简单地实现某些复杂的数据处理. 下面我谈谈与exists有关的三个方面. all 与 any 首先,看到了 ...
- PTA数据结构与算法题目集(中文) 7-37 模拟EXCEL排序 (25 分)
PTA数据结构与算法题目集(中文) 7-37 模拟EXCEL排序 (25 分) 7-37 模拟EXCEL排序 (25 分) Excel可以对一组纪录按任意指定列排序.现请编写程序实现类似功能. ...
- P3381 【模板】最小费用最大流 题解
CSDN同步 原题链接 前置知识: 从三种算法剖析网络流本质 简要题意: 给定网络图,求图的最大流,以及流量为最大流时的最小费用. 现在假设你们看了那篇网络流博客之后,所有人都会了 \(\text{E ...
- 使用Azure Rest API获得Access Token介绍
背景 本文主要介绍如何获取如何获取Azure Rest API的访问token,所采用的是v2.0版本的Microsoft标识平台,关于1.0和2.0的区别可以参考 https://docs.azur ...
- 阿里云服务器扩展分区和文件系统_Linux数据盘
官方文档永远是最好的 https://help.aliyun.com/document_detail/25452.html?spm=a2c4g.11186623.6.786.5fde4656Ln6AO ...
- C语言数据结构队列
#include<stdio.h>#include<stdlib.h>struct Node { int data; Node *next;};struct Queue { ...