谁能告诉我为什么我不能使用PHP显示PDF文件?左下角显示正在加载,一直没有消失。我可以使用控制面板并查看pdf文件,所以我知道这是一个有效的pdf文件。
代码如下:
<?php
session_start();
$path = '/show_bills/';
// The location of the PDF file on the server.
$filename = $path.$_SESSION['ShowID']."_show_bill.pdf";
header("Content-type: application/pdf");
header("Content-Length: " . filesize($filename));
readfile($filename);
exit;
?>
谢谢,
维克
我几乎可以肯定这个文件根本不存在。$path后面有一个斜杠,表示脚本将在服务器的最根目录
中查找该文件。您可以使用file_exists函数检查文件是否存在
http://uk3.php.net/manual/en/function.file-exists.php另外,尝试在不指定标题的情况下输出文件-可能会输出PHP警告