ZipArchive Method for php packaging compressed files

Source: Internet
Author: User
Tags ziparchive
Archive. php, for example: 01? Php02$zipnewziparchive;initialize this class 03if(unzip zip-open(test.zip) TRUE ){

It is very simple to use ZipArchive to compress files. The php official website has provided me with many examples. You can refer to http://www.php.net/manual/zh/class.ziparchive.php, for example: 01? Php 02 $ zip = new ZipArchive; // first instantiate this class 03 if ($ zip-open ('test.zip ') === TRUE ){

It is very simple to use ZipArchive to compress files. The php official website has provided me with many examples. You can refer to http://www.php.net/manual/zh/class.ziparchive.php, for example:

01

02 $zip = new ZipArchive; // Instantiate this class first

03 if ($zip->open('test.zip') === TRUE) { // The compressed file test.zip is available later.

04 $zip->addFile('too.php');

05 $zip->addFile('test.php'); // Upload the too.php and test.php files to the test.zip package.

06 $zip->close(); // Close

07 echo 'ok';

08 } else {

09 echo 'failed';

10 }

11 ?>

The following are some parameter descriptions:

Show source code printing help

01

02

03 /******** Optional ziparchive parameter *******/

04 /*

05 1.ZipArchive::addEmptyDir

06

07 Add a new file directory

08

09 2.ZipArchive::addFile

10

11 Add the file to the specified zip package.

12

13 3.ZipArchive::addFromString

14

15 Add the content to the added file at the same time.

16

17 4.ZipArchive::close

18

19 Disable ziparchive

20

21 5.ZipArchive::extractTo

22

23 Decompress the package

24

25 6.ZipArchive::open

26

27 Open a zip package

28

29 7.ZipArchive::getStatusString

30

31 Returns the status content during compression, including error information and compression information.

32

33 8.ZipArchive::deleteIndex

34

35 Delete a file in the compressed package, for example, deleteIndex (0). Delete the first file.

36

37 9.ZipArchive::deleteName

38

39 Delete a file name in the package and delete the file.

40 ......

41 */

42

43 ?>

In short, it is more convenient to use ZipArchive for File compression as long as you have php5.2 or later versions. Which of the following operations is faster than PclZip? This Lei Zi has not been tested yet. If you are interested, you can try again and again.

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.