我正在使用symfony 1.4。我創建了一個pdf並在新窗口中顯示。當我點擊其他鏈接時,我顯示了pdf後,我得到了下面的代碼。我認爲它顯示我的html源文件。HTTP頭問題
如何解決此問題?
141070HTTP/1.1 200 OK日期:週三,13 2011年4月13時22分07秒格林尼治標準時間服務器:Apache的 /2.0.63(Unix的)的mod_ssl/2.0.63 的OpenSSL/0.9.8e-FIPS- RHEL5 mod_auth_passthrough/2.1 mod_bwlimited/1.4的FrontPage/5.0.2.2635 X供電-者:PHP/5.3.4截止日期:週四, 1981年11月19日8點52分○○秒GMT 緩存控制:無店鋪,無-cache, 必須重新驗證,post-check = 0, 預檢查= 0 Pragma:no-cache Keep-Alive:timeout = 15,max = 94 連接:Keep-Alive T ransfer-Encoding:chunked Content-Type:text/html; charset = utf-8 ... ... ...
這是我的symfony代碼來顯示pdf。
$this->getResponse()->clearHttpHeaders();
$this->getResponse()->setHttpHeader('Content-Disposition', 'inline; filename="' . basename($path) . '"');
$this->getResponse()->setHttpHeader('Content-type', 'application/pdf');
$this->getResponse()->setHttpHeader('Pragma: public', true);
$this->getResponse()->setHttpHeader('Expires', 0);
$this->getResponse()->setHttpHeader('Content-Transfer-Encoding', 'binary');
$this->getResponse()->setHttpHeader('Content-Length', filesize($path));
$this->getResponse()->sendHttpHeaders();
ob_clean();
flush();
echo readfile($path);
我明白了。但我不知道它來自哪裏。我已經使用symfony。我只是通過點擊標籤來渲染另一個頁面。你能告訴我它究竟是從哪裏來的? – JohnnyeM 2011-04-15 05:44:51
請發佈您收到的所有標題行。我從來沒有和Symphony一起工作,所以我不能說它是如何呈現它的輸出。我會猜想你不能像交響曲那樣修改頭文件。您是否使用任何檢查工具檢查了您的回覆內容? FireBug,提琴手? Wireshark的?和tcpdump? – jishi 2011-04-15 07:34:09