Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
下载.jpg文件时PHP文件损坏?_Php_Filesize - Fatal编程技术网

下载.jpg文件时PHP文件损坏?

下载.jpg文件时PHP文件损坏?,php,filesize,Php,Filesize,通过我的网站上的URL下载.jpg文件时,该文件会损坏。我没有测试过很多文件but.pdf的下载。我在文件中看到以下错误: b>警告:filesize()[function.filesize]:在第89行的/home/content/91/4761691/html/pages/download.php中,sunny.jpg的stat失败 第89行是filesize()函数,如下所示 $ID=stripslashes($_GET['recordid']); $file = $_GET['file'

通过我的网站上的URL下载.jpg文件时,该文件会损坏。我没有测试过很多文件but.pdf的下载。我在文件中看到以下错误:

b>警告:filesize()[function.filesize]:在第89行的/home/content/91/4761691/html/pages/download.php中,sunny.jpg的stat失败

第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);
$ID=stripslashes($\u GET['recordid']);
$file=$\u获取['file'];
//存储文件的目录的绝对路径。
$path='../photos/'$ID.“/”;
标题(“Pragma:public”);
标题(“到期日:0”);
标头(“缓存控制:必须重新验证,后检查=0,前检查=0”);
标题(“内容类型:应用程序/强制下载”);
//标题(“内容处置:附件;文件名=$file”);
标题('Content-Disposition:attachment;filename=“.”.$file.'”);
标题(“内容描述:文件传输”);
标题('Accept-Ranges:bytes');

标题('Content-Length:'.filesize($file)) 您正在编写
readfile($path.$file)
输出文件,因此我假设您还应该编写
filesize($path.$file)
获取同一文件的文件大小

header('Content-Length: ' . filesize($path.$file));
readfile($path.$file);

$path.$file
的值是多少?看起来它得到了,谢谢!我的浏览器是否会认为默认情况下该文件是.wav文件,但会使用图像查看器应用程序打开?我的文件关联是为图像查看器应用程序设置的……它可能与您正在传播的内容类型有关(
应用程序/force download
)。请尝试在此处指定适当的内容类型。