Php uses zip & nbsp; in PHP, you can use PHP's own ZIP function to package and decompress some files. this is more convenient than other languages. the method is summarized as follows: 1. open PHP. extended extension in INI, enabled (this function is available after PHP5.2) & nbsp; extension = php_zip. use zip in php
In PHP, you can use the php zip function to pack and decompress some files.
The methods are as follows:
1. open the extended extension in PHP. INI and enable it (this function will be available in PHP 5.2 and later)
Extension = php_zip.dll
2. compressed files
Open ($ file, $ ow? ZIPARCHIVE: OVERWRITE: ZIPARCHIVE: CREATE) === TRUE) {// add a file $ zip-> addFile ("c: \ master.txt "); // a1.txtwill be saved to a2.txt $ zip-> addFile ("c: \ a1.txt", "c: \ a2.txt"); $ zip-> addFile ("c: \ a3.txt "); // close $ zip-> close () ;}?>
3. decompress
$ Zip = new ZipArchive (); // open master.zip if ($ zip-> open ("master.zip") === TRUE) {// decompressed path $ zip-> extracloud ("/path/to/folder/"); $ zip-> close ();} // extract only one file // Open master.zip for extracting single files if ($ zip-> open ("master.zip") === TRUE) {// Will extract only fonts.css from master.zip to given path. $ zip-> extracelist ("/path/to/folder/", "fonts.css"); $ zip-> close ();} // decompress multiple files if ($ zip-> open ("master.zip") === TRUE) {$ files = array ("fonts.css", "master.css "); $ zip-> extracloud ("/path/to/folder/", $ files); $ zip-> close ();}