
thinkphp 导出 excel 报错“net::err_invalid_response”
在使用 thinkphp 导出 excel 时遇到“net::err_invalid_response”错误,该错误通常出现在将本地代码部署到正式环境时。
这个问题的根源在于 php 版本。本地和线上环境的 php 版本可能不同。问题答案建议,在 php 5.5 版本中,该代码运行正常。因此,建议检查线上环境的 php 版本是否过高。
解决此错误的方法是:
立即学习“PHP免费学习笔记(深入)”;
header('Content-Type: application/vnd.ms-excel');
header("Content-Disposition: attachment;filename=\"$fileName\"");
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output'); //文件通过浏览器下载以上就是ThinkPHP导出Excel报错“net::ERR_INVALID_RESPONSE”是什么原因?的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号