public function download_img_all(){
//图片数组
$res=["http://hyxun-erp-wwwroot-ginny.oss-cn-hangzhou.aliyuncs.com/img/6ee6706a6c178e5b2edf988f832bac4d925ffbe9.jpeg", "http://hyxun-erp-wwwroot-ginny.oss-cn-hangzhou.aliyuncs.com/img/5a05269ca0418f5954055cf6ca70aa073122390f.jpeg"
, "http://hyxun-erp-wwwroot-ginny.oss-cn-hangzhou.aliyuncs.com/img/a22c1001f8b091bcd6a77663a7c39e710878e6be.jpeg"
,"http://hyxun-erp-wwwroot-ginny.oss-cn-hangzhou.aliyuncs.com/img/9c9a38354249cfe408aee02f80a5a6f2854d6d19.jpeg"
, "http://hyxun-erp-wwwroot-ginny.oss-cn-hangzhou.aliyuncs.com/img/56efe9f8eaf6e86c8ce646daa06234f70f4d9c02.jpeg"
,"http://hyxun-erp-wwwroot-ginny.oss-cn-hangzhou.aliyuncs.com/img/3d530014e30427fcf04a330f86caad77a9348ccd.jpeg"
, "http://hyxun-erp-wwwroot-ginny.oss-cn-hangzhou.aliyuncs.com/img/f13ea3162d51bbba543ab297cb6cc9001a0d460b.jpeg"
,"http://hyxun-erp-wwwroot-ginny.oss-cn-hangzhou.aliyuncs.com/img/55eb2e7b06b4bbacda53e8b2ae3a0498802faa24.jpeg"
];
//创建压缩包的路径及其名字
$filename = $_SERVER['DOCUMENT_ROOT'].'/Dwonload.zip';
$zip = new \ZipArchive;
$zip->open($filename,$zip::CREATE);
//往压缩包内添加目录
$zip->addEmptyDir('images');
foreach ($res as $k=>$value) {
$fileData = file_get_contents($value);
if ($fileData) {
$add = $zip->addFromString('images/'.$value, $fileData);
}
}
$zip->close();
//打开文件
//下载文件
ob_end_clean();
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename='.time().'.zip');
header('Content-Length: '.filesize($filename));
error_reporting(0);
readfile($filename);
flush();
ob_flush();
}
感谢博主,喝杯咖啡~
感谢博主,喝杯咖啡~
当你觉得自己又丑又穷,一无是处时,别绝望,因为至少你的判断还是对的。