如题,
注意:不是做图片采集,图片已在服务器上,需求是用户勾选了几张图片后,下载到用户的电脑上,单个没问题,多个不知道如何弄
回复内容:
如题,
注意:不是做图片采集,图片已在服务器上,需求是用户勾选了几张图片后,下载到用户的电脑上,单个没问题,多个不知道如何弄
<code class="php">$zip = new \ZipArchive;//压缩文件名$filename = 'download.zip';//新建zip压缩包$zip->open($filename,\ZipArchive::OVERWR<div>本文#来源gaodai.ma#com搞##代!^码7网</div><pre>搞代gaodaima码
ITE);//把图片一张一张加进去压缩foreach ($images as $key => $value) { $zip->addFile($value);}//打包zip$zip->close();//可以直接重定向下载header(‘Location:’.$filename);//或者输出下载header(“Cache-Control: public”); header(“Content-Description: File Transfer”); header(‘Content-disposition: attachment; filename=’.basename($filename)); //文件名 header(“Content-Type: application/force-download”);header(“Content-Transfer-Encoding: binary”);header(‘Content-Length: ‘. filesize($filename)); //告诉浏览器,文件大小 readfile($filename);