仅做记录...
$file_path = "/xxx/xxx/xx.jpg";
if(!file_exists($file_path)){
//此处为日志记录和错误提示返回信息.逻辑根据自己的情况处理
$this->i("未找到图片:{$file_path}");
$this->returnError(333, "the files is not found");
exit;
}else{
$fp = fopen($file_path, "r+");
$file_size = filesize($file_path);
//返回的文件
Header("Content-type: application/octet-stream");
//按照字节格式返回
Header("Accept-Ranges: bytes");
//返回文件大小
Header("Accept-Length: ".$file_size);
//弹出客户端对话框,对应的文件名
Header("Content-Disposition: attachment; filename=".$name);
//分段读取
$buffer = 1024 << 2;
while(!feof($fp)){
$file_data = fread($fp, $buffer);
echo $file_data;
flush();
}
//关闭文件
fclose($fp);
exit;
}