IE (HTTPS):从 php 文件生成 pdf 不起作用
这是我的问题。 我正在尝试调用页面: 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 响应的标题。 它们是相同的。
有没有人有什么建议? 需要更多信息吗?
编辑:如果有帮助,这里是响应标头和内容的第一行:
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
编辑:此外,提取 pdf 文件的页面实际上使用 HTTPS HTTP 的。
预先感谢,
〜扎克
Here is my issue. I am trying to call a page: foo.php?docID=bar and return a PDF to the screen which is stored as a BLOB in the DB.
Here is the portion of my code which actually returns the 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.');
}
This works perfectly fine in Firefox.
However, in IE, it doesn't show anything at all. If i'm on another page (i.e. google.com), and I type in the URL to go to this page, it will say it's done, but I will still have google.com on my screen.
I checked the headers for the responses from both firefox and IE. They are identical.
Does anyone have any suggestions? Need more information?
EDIT: If it helps at all, here's the response header and the first line of the content:
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: Also, the page which pulls out the pdf file actually uses HTTPS instead of HTTP.
Thanks in advance,
~Zack
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我明白了问题所在。 这是一个处理 IE、HTTPS 和插件的 IE 错误。 (请参阅此处)
这是一个缓存问题。 当我设置:(
参见此处)时,PDF位于缓存足够长的时间,以便 adobe reader 附加组件能够获取它。
I figured out what the issue was. It's an IE bug dealing with IE, HTTPS and addons. (See here)
It was a caching issue. When I set:
(see here), the PDF was in cache long enough for the adobe reader add-on to grab it.
我也遇到了这个问题,我使用了以下似乎工作正常
I had this issue too, i used the following which seems to work fine
试试这个:
另外,如果您正在使用会话,您可以尝试设置
或
Try this:
Also, if you are using sessions, you can try setting
or
这是我需要更改的唯一标头:
This was the only header I needed to change:
我认为您需要添加更多标题。
I think you need to add more headers.