php header 不起作用,php – symfony:setHttpHeader()不起作用,header()没有
你的問題在這里:
return sfView::NONE;
將其更改為:
return sfView::HEADERS_ONLY;
由于額外的評論編輯更新.
由于您嘗試下載pdf,因此您無法正確解決問題.不要使用sendContent().請參閱下文(這是我編寫的生產(chǎn)網(wǎng)站的片段,已經(jīng)證明可以在所有主流瀏覽器中使用):
$file = '/path/to/file.pdf';
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setStatusCode(200);
$this->getResponse()->setContentType('application/pdf');
$this->getResponse()->setHttpHeader('Pragma','public'); //optional cache header
$this->getResponse()->setHttpHeader('Expires',0); //optional cache header
$this->getResponse()->setHttpHeader('Content-Disposition',"attachment; filename=myfile.pdf");
$this->getResponse()->setHttpHeader('Content-Transfer-Encoding','binary');
$this->getResponse()->setHttpHeader('Content-Length',filesize($file));
return $this->renderText(file_get_contents($file));
總結(jié)
以上是生活随笔為你收集整理的php header 不起作用,php – symfony:setHttpHeader()不起作用,header()没有的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ginkgo php,【行业资讯】PHP
- 下一篇: php 接口curl,php中接口强大之