Use Zip in PHP

Source: Internet
Author: User
Tags php source code ziparchive
Introduction: This is a detailed page of PHP using Zip, introduced and php,php, zip PHP with the use of zip-related knowledge, skills, experience, and some PHP source code.

class= ' pingjiaf ' frameborder= ' 0 ' src= ' http://biancheng.dnbcw.info/pingjia.php?id=350525 ' scrolling= ' no ' > in PHP, You can use PHP's own zip function to package and decompress certain files, which is more than other languages
are very convenient, the method summary is as follows:

1 Open the extension extension in php.ini, enable (PHP 5.2 has this feature later)
extension= Php_zip.dll

2 compressing files
 
  Open ($file, $ow? Ziparchive::overwrite:ziparchive::create) ===true) {   //Add a file   $zip->addfile ("C:\\master.txt");      A1.txt will be kept pressurized to A2.txt   $zip->addfile ("C:\\a1.txt", "C:\\a2.txt");      $zip->addfile ("C:\\a3.txt");      Close    $zip->close ();     }?>


3 Decompression
$zip = new Ziparchive (); Open Master.zip  if ($zip->open ("master.zip") = = = TRUE)  {   //unzipped path   $zip->extractto ("/path/to/ folder/");   $zip->close (); }//Unzip only one file  //Open Master.zip for extracting single files if ($zip->open ("master.zip") = = = = TRUE)  {   //Wil L extract only fonts.css from Master.zip to given path.   $zip->extractto ("/path/to/folder/", "fonts.css");   $zip->close (); }//Unzip multiple files  if ($zip->open ("master.zip") = = = TRUE)  {      $files = array ("Fonts.css", "master.css");   $zip->extractto ("/path/to/folder/", $files);   $zip->close (); }

Love EE focus on Java Michael Jackson Video station JSON online tool

Http://biancheng.dnbcw.info/php/350525.html Pageno:3
  • 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.