Ask the company to package and download the ZIP file. every colleague of the company will summarize the work every week. then, the relevant data will be downloaded in a table. now we need to package and download the data each time. read the content of all colleagues of the 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 directly ,......... 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?