【发布时间】:2015-04-27 00:55:08
【问题描述】:
通过我网站上的 URL 下载 .jpg 文件时,文件已损坏。我没有测试很多文件,但 t.pdf 的下载很好。我在文件中看到以下错误:
b>警告:filesize() [function.filesize]: /home/content/91/4761691/html/pages/download.php中的sunny.jpg stat failed第 89 行
第 89 行是 filesize() 函数,如下所示...
$ID=stripslashes($_GET['recordid']);
$file = $_GET['file'];
// the absolute path to your directory storing your files.
$path = '../photos/' . $ID . '/';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
//header("Content-Disposition: attachment; filename=$file");
header('Content-Disposition: attachment;filename="'.$file.'"');
header("Content-Description: File Transfer");
header('Accept-Ranges: bytes');
header('Content-Length: ' . filesize($file)); <========== line 89
readfile($path.$file);
关于为什么会失败以及如何解决的任何想法?
【问题讨论】:
-
$path.$file的值是多少?