PHP code for packaging and downloading images

Source: Internet
Author: User
Tags ziparchive
For example, note: images are not collected and are already on the server. You need to select a few images and download them to your computer, I don't know how to solve the problem,
Note: images are not collected. images are already on the server. You need to select a few images and download them to your computer. There is no problem for each image.

Reply content:

For example,
Note: images are not collected. images are already on the server. You need to select a few images and download them to your computer. There is no problem for each image.

$ Zip = new \ ZipArchive; // compressed file name $ filename = 'download.zip '; // create a zip package $ zip-> open ($ filename, \ ZipArchive: OVERWRITE ); // Add one image to the compressed foreach ($ images as $ key = >$ value) {$ zip-> addFile ($ value );} // zip $ zip-> close (); // you can directly redirect the download header ('location :'. $ filename); // or the output download header ("Cache-Control: public"); header ("Content-Description: File Transfer"); header ('content-disposition: attachment; filename = '. basename ($ filename); // file name header ("Content-Type: application/force-download"); header ("Content-Transfer-Encoding: binary "); header ('content-Length :'. filesize ($ filename); // tell the browser the file size readfile ($ filename );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.