我通过网络服务以这种方式获得一些图片路径:
0 => string '/home/41/38/58/96/photos/1.jpg'
1 => string '/home/41/38/58/96/photos/2.jpg'
2 => string '/home/41/38/58/96/photos/3.jpg'
我正在尝试通过PHP脚本将它们下载到浏览器中:
foreach($files as $index => $files){
if($index !== 'debug'){
$file_name = basename($file);
$final_file = @fopen($file,"rb");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
header("Content-Type: image/jpeg");
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename=\"$file_name\"");
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($file));
print(@fread($final_file, filesize($file)));
ob_flush();
flush();
@fclose($final_file);
}
}
问题是,即使我的数组包含你看到的三个链接,我也只得到一张图片。所以我做错了。
答案 0 :(得分:3)