这是我的问题。我正在尝试调用页面: foo.php?docID=bar 并将 PDF 返回到屏幕,该 PDF 作为 BLOB 存储在数据库中。
这是我的代码中实际返回 PDF 的部分:
$docID = isset($_REQUEST['docID']) ? $_REQUEST['docID'] : null;
if ($docID == null){
die("Document ID was not given.");
}
$results = getDocumentResults($docID);
if (verifyUser($user, $results['ProductId'])){
header('Content-type: application/pdf');
// this is the BLOB data from the results.
print $results[1];
}
else{
die('You are not allowed to view this document.');
}
这在 Firefox 中工作得非常好。
但是,在 IE 中,它根本不显示任何内容。如果我在另一个页面(即 google.com)上,并且输入要转到此页面的 URL,它会说已完成,但我的屏幕上仍会显示 google.com。
我检查了 Firefox 和 IE 响应的标题。它们是相同的。
有没有人有什么建议?需要更多信息吗?
EDIT:如果有帮助的话,这是响应头和内容的第一行:
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 349930
Content-Type: application/pdf
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: PHP/5.1.2
Set-Cookie: PHPSESSID=cql3n3oc13crv3r46h2q04dvq4; path=/; domain=.example.com
Content-Disposition: inline; filename='downloadedFile.pdf'
X-Powered-By: ASP.NET
Date: Tue, 21 Apr 2009 16:35:59 GMT
%PDF-1.4
EDIT:另外,提取pdf文件的页面实际上使用的是HTTPS而不是HTTP。
提前致谢,
~Zack