jjzjj

setHttpHeader

全部标签

php - 交响乐 1.4 : Best way provide a file download without using a template/view

当然,其他一些人已经在stackoverflow上讨论了这些问题,但并非所有答案都适合我,而且他们通常不提供symfony安装的版本。我阅读的主题:Sendattachment/DownloadfilefromSymfonyactionHowtodownloadafileonclickingthefilepathusingPHP-Symfony?symfony:setHttpHeader()doesn'twork,header()does这就是我要问您如何在symfony1.4中处理文件下载(不使用View)的目的?在我所有的用例中,我都需要一个模板文件来呈现响应。如果我由于Contr

php - symfony : setHttpHeader() doesn't work, header() 确实

我在symfony中构建了一个简单的操作,它通过wkhtmltopdf生成一个PDF文件并将其输出到浏览器。代码如下:$response=$this->getResponse();$response->setContentType('application/pdf');$response->setHttpHeader('Content-Disposition',"attachment;filename=filename.pdf");$response->setHttpHeader('Content-Length',filesize($file));$response->sendHttp