Recently developed a picture website with CodeIgniter, found that single file download is easy to implement, bulk download, it is not easy to implement.
The following is a reference to the online example, written a test file, encounter the same problem and do not know how to deal with friends can refer to.
Ideas:
① combine the picture information to be downloaded into the $IMGS array
② Package The image you want to download into a ZIP archive
③ Download the compressed package, delete the temporary zip file on the server
<?PHP$imgs[] = ' http://demo.pic.com/column_f/large/IMG_Af8P_15.jpg ';$imgs[] = ' http://demo.pic.com/column_f/large/IMG_l89P_08.jpg ';$filename= ' Tmp.zip ';$zip=Newziparchive ();$zip->open ($filename, Ziparchive::OVERWRITE);foreach($imgs as $key=$vo) { $fileData=file_get_contents($vo); if($fileData) { $zip->addfromstring ($key.‘. JPG ',$fileData); }}$zip-close ();$file=fopen($filename, "R");Header("Content-type:application/octet-stream");Header("Accept-ranges:bytes");Header("Accept-length:".)filesize($filename));Header("Content-disposition:attachment; Filename=imgages.zip ");//transfer only 1024 bytes of data to the client at a time$buffer= 1024;// while(!feof($file)) { //read the file into memory $file _data=fread($file,$buffer); //each time 1024 bytes of data is echoed to the client Echo $file _data;}fclose($file);unlink($filename);//Deleting Files