Introduction: This is a detailed page for PHP to use zip. It introduces the knowledge, skills, experience, and some PHP Source Code related to using zip in PHP, PHP, and zip PHP.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 350525 'rolling = 'no'>
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
<? // Creating object of the ziparchive $ zip = new ziparchive (); $ ow = 1; $ file = "C: \ master.zip "; if ($ zip-> 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 ();}
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/350525.html pageno: 3