【发布时间】:2016-07-26 10:01:31
【问题描述】:
我有一个csv.phtml,我有所有行和列的值
csv.phtml:
ID,column1,column2
1,french_words,dutch words
2,french_words,dutch words
10000,randrom words, random words
php:
$html = $this->view->render('print/csv.phtml');
// this works, it prints $html
//echo $html;
//exit;
// from here: it does not work
$this->getResponse()
->setHeader('Content-Disposition', 'attachment; filename=report.csv')
->setHeader('Content-Type', 'application/csv')
->setBody($html)
->sendResponse();
exit;
我该如何解决? $html 中是否有一些奇怪的字符导致应用程序/csv 无法呈现?我怎样才能准确地找到那个无效的部分?
【问题讨论】:
-
看起来你的服务器已经崩溃了。在堆栈溢出时,您需要提供更多信息并更笼统地回答您的问题,因为他们需要帮助社区......而不仅仅是您自己。
-
尝试从
curl访问该 URL,并查看它的响应。$ curl -i http://hide-it.com/report查看服务器的错误日志。这不是“浏览器崩溃”,而是浏览器告诉您服务器没有响应。 -
日志中有什么?检查 apache|nginx 日志。如果您使用的是框架(例如 Symfony),请同时检查框架日志。
-
这怎么可能是服务器问题,我在同一台服务器上拥有同一张表上的所有其他报告,除了这个是 /report 控制器之外,它们都工作正常
-
还要检查响应本身(chrome 检查器工具或立即 curl)。
标签: php google-chrome csv