PHP用header进行文件下载
Jun 23, 2016 pm 02:16 PM
PHP csv 下载
各位,我用header导出csv,我在本地测试可以成功下载导出,但是在服务器就只能直接显示在网页上了,不能下载,为什么会这样?我的header是这样的:
header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream");header("Content-Type: application/vnd.ms-excel");header("Content-Type: application/force-download"); header("Pragma: public"); header("Accept-Ranges: bytes"); header("Expires: 0");header('Content-Disposition: attachment;filename="data.csv"');header("Content-Transfer-Encoding: binary");header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header('Cache-Control: private',false);
回复讨论(解决方案)
header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream");header("Content-Type: application/vnd.ms-excel");header("Content-Type: application/force-download"); header("Pragma: public"); header("Accept-Ranges: bytes"); header("Expires: 0");header('Content-Disposition: attachment;filename=data.csv');header("Content-Transfer-Encoding: binary");header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header('Cache-Control: private',false);
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Type: application/vnd.ms-excel");
header("Content-Type: application/force-download");
header("Pragma: public");
header("Accept-Ranges: bytes");
header("Expires: 0");
header('Content-Disposition: attachment;filename= data.csv');
header("Content-Transfer-Encoding: binary");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Cache-Control: private',false);
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Type: application/vnd.ms-excel");
header("Content-Type: application/force-download");
header("Pragma: public");
header("Accept-Ranges: bytes");
header("Expires: 0");
header('Content-Disposition: attachment;filename= data.csv');
header("Content-Transfer-Encoding: binary");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Cache-Control: private',false); 改了哪里?
但是在服务器就只能直接显示在网页上了
是指代码还是csv的内容。没看出代码有什么问题。
但是在服务器就只能直接显示在网页上了
是指代码还是csv的内容。没看出代码有什么问题。
是CSV的内容啊
但是在服务器就只能直接显示在网页上了
是指代码还是csv的内容。没看出代码有什么问题。
在网页上输出的是CSV的内容啊,求问大神是怎么回事啊?
但是在服务器就只能直接显示在网页上了
是指代码还是csv的内容。没看出代码有什么问题。
在网页上输出的是CSV的内容啊,求问大神是怎么回事啊?
信息不全,不好说,检查下文件的编码格式,是否有BOM头,如果有bom头的话,可能会输出导致之后的header失效。

Article chaud

Outils chauds Tags

Article chaud

Tags d'article chaud

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds

11 meilleurs scripts de raccourcissement d'URL PHP (gratuit et premium)

Travailler avec les données de session Flash dans Laravel

Misque de réponse HTTP simplifié dans les tests Laravel

Construisez une application React avec un Laravel Back End: Partie 2, React

Curl dans PHP: Comment utiliser l'extension PHP Curl dans les API REST

12 meilleurs scripts de chat PHP sur Codecanyon
