PHP package and download multiple files

Source: Internet
Author: User
Tags ziparchive
PHP5.2 + Built-in support for multi-file packaging, using the ZipArchive class. To package and download multiple files, take two steps. The first step is to use ZipArchive to compress multiple files and then use the header command to generate the download operation. To recursively add all subdirectories and files in the directory, You need to derive a class. For details, refer to: 1. php. netmanualencia.

PHP5.2 + Built-in support for multi-file packaging, using the ZipArchive class. To package and download multiple files, take two steps. The first step is to use ZipArchive to compress multiple files and then use the header command to generate the download operation. To recursively add all subdirectories and files under the directory, You need to derive a class, refer to: 1. http://php.net/manual/en/cla

PHP5.2 + Built-in support for multi-file packaging, using the ZipArchive class.

To package and download multiple files, take two steps. The first step is to use ZipArchive to compress multiple files and then use the header command to generate the download operation.

To recursively add all subdirectories and files in the directory, You need to derive a class. For details, refer:

1. http://php.net/manual/en/class.ziparchive.php#110719

In step 2, read and output the file to the client using readfile. For details, refer:

2. http://php.net/manual/zh/function.readfile.php#refsect1-function.readfile-examples

If the downloaded zip file is invalid, it may be because the ob_clean () command is not executed when the stream file is being downloaded. As a result, the early output buffer is accidentally added to the file.


By iefreer

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.