我在symfony中構建了一個簡單的動作,它通過wkhtmltopdf生成一個PDF文件並將其輸出到瀏覽器。symfony:setHttpHeader()不起作用,header()做
下面的代碼:
$response = $this->getResponse();
$response->setContentType('application/pdf');
$response->setHttpHeader('Content-Disposition', "attachment; filename=filename.pdf");
$response->setHttpHeader('Content-Length', filesize($file));
$response->sendHttpHeaders();
$response->setContent(file_get_contents($file));
return sfView::NONE;
該工程在我的本地開發環境很好 - 我的瀏覽器獲得頭不如預期,顯示下載對話。
現在我更新了測試環境,使用PHP 5.3.5-0.dotdeb.0運行Apache 2.2.9-10 + lenny9。 如果我將其稱爲URL現在測試環境中,我的瀏覽器沒有得到任何自定義設置頭:
Date Mon, 07 Mar 2011 10:34:37 GMT
Server Apache
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Transfer-Encoding chunked
如果我通過header()函數在我的行動手動設置,螢火顯示標題爲預期。 有人知道什麼可能是錯的?它是一個symfony錯誤,或者一個php或apache2配置問題?我不明白。 : -/
在此先感謝!
@teonanacatl ...選擇你的一個帳戶並使用它當前正在使用清楚兩個不同的帳戶的http:。/ /stackoverflow.com/users/647993/teonanacatl和http://stackoverflow.com/users/480353/teonanacatl –