我让我的用户下载使用该代码的PDF文件:下载PDF - 不能打开它
的$db->Record['file']
包含文件的相对路径。
访问一个加载pdf的虚拟页面,所以他们实际上并没有在url中看到“text.pdf”。我改变了文件的标题来实现这一目标:
$downloadfile = '/data/srv/www/vhosts/htdocs'.$db->Record['file'];
$filename = basename($downloadfile);
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="'.$filename.'"');
readfile($downloadfile);
下载的工作没有任何问题,但是当我尝试打开它,下面的错误ocurrs:
The PDF file could not be openend, the type is not supported or the file
was damaged.
我怎样才能解决这个问题?
不是:当我直接下载文件时,意思是通过http://.../text.pdf
访问并打开它,一切工作正常。
下载的文件实际上包含什么? – 2010-09-01 11:15:11
我会打赌啤酒里有PHP错误信息在文件中。 – 2010-09-01 11:17:32