Can you package and upload a ZIP file?

Source: Internet
Author: User
Tags ziparchive
Ask the company to package and download the ZIP file. every colleague of the company needs to summarize the work every week. then, the relevant data should be downloaded in a table. now, the package and download function should be implemented to read the content of all colleagues of a week. in summary, a TXT file is then packaged into a ZIP package and then provided for download. I want to know how to implement it? Please give me the code ------ solution --------------------............. How to package and download ZIP files
Every colleague of the company will summarize the work every week, and then the relevant data will be downloaded and packaged in a table. the package function is used to read the contents of all colleagues of the week. the summary of each colleague is a TXT file. then pack all the TXT files into a ZIP package and download them. I want to know how to implement it? Please give me the code directly.

------ Solution --------------------
..............

Provide a idea. first, traverse and change the files in the directory.

Use the ZipArchive class that comes with php to perform operations.

It's easy.
------ Solution --------------------
Give you a rough code
PHP code
// CREATE a zip object, and then CREATE a compressed file test1.zip $ zip = new ZipArchive (); $ filename = "test1.zip"; if ($ zip-> open ($ filename, ZIPARCHIVE: CREATE )! = TRUE) {exit ("cannot open <$ filename> \ n");} // use the brother's algorithm on the top to traverse the circular folder, get $ filename of each file, code omitted... //... if ($ zip-> open('test1.zip ') === TRUE) {$ zip-> addFile ($ filename, $ newname); $ zip-> close (); echo 'OK';} else {echo 'failed ';}
------ Solution --------------------
Ah, speechless. Why are there always people who directly need code instead of asking for ideas on csdn?

How can we teach people to fish and how can we teach them to fish?
------ Solution --------------------
$ Str = 'E: \ "Program Files" \ WinRAR \ WinRAR.exe a-ep1-r-o +-m5-df zongjie.rar zongjie.txt ';
System ($ str );
------ Solution --------------------
Faisun_zip_v10, which can be compressed. for details, refer
------ Solution --------------------
Discussion
Why are there three equal signs in the code?

------ Solution --------------------
That's why I didn't clarify the problem at the beginning...

Make sure that the ext folder in the php installation folder contains the php_zip.dll file.
Modify php. ini
Cancel the following comments
Extension = php_zip.dll
Restart apache

You only need to start this extension to use that class.
Which version is the main PHP version?


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.