• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP用header开展文件下载

php 搞代码 4年前 (2022-01-24) 14次浏览 已收录 0个评论

PHP用header进行文件下载
各位,我用header导出csv,我在本地测试可以成功下载导出,但是在服务器就只能直接显示在网页上了,不能下载,为什么会这样?
我的header是这样的:

header("Content-Description: File Transfer"); <br />header("Content-Type: application/octet-stream");<br />header("Content-Type: application/vnd.ms-excel");<br />header("Content-Type: application/force-download"<p>+本文来源gao!%daima.com搞$代*!码9网(</p><strong>搞gaodaima代码</strong>); <br />header("Pragma: public"); <br />header("Accept-Ranges: bytes"); <br />header("Expires: 0");<br />header('Content-Disposition: attachment;filename="data.csv"');<br />header("Content-Transfer-Encoding: binary");<br />header("Cache-Control: must-revalidate, post-check=0, pre-check=0");<br />header('Cache-Control: private',false);

PHP csv 下载

发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址