Specific implementation method of compressing folders in PHP_PHP tutorial

WBOY
Release: 2016-07-15 13:32:31
Original
1038 people have browsed it

However, there are no functions for folder operations in the zlib library (of course, we can also write one ourselves, but this is too troublesome), we can download it online There are some ready-made tools written by predecessors that extend the zlib function library.

The specific implementation code of PHP compressed folder:

  1. < ?php
  2. require_once("archive.php");
  3. $test = new zip_file("app.zip");
  4. $ test->set_options(
  5. array(
  6. 'basedir' => dirname($modpath),
  7. 'inmemory' => 0, //Does not compress the memory.
    but stores it directly in Disk. If you want to compress the download, you can choose 1
  8. 'recurse' => 1, // Whether to compress subdirectories,
    resurse, what does recursion mean?
  9. 'storepaths' = > 1, //Whether to store the directory structure, I choose yes.
  10. 'overwrite' => 1, //Whether to cover
  11. 'prepend' = > "", //Unknown
  12. 'followlinks' => 0, //Unknown
  13. 'method' => 1, //Unknown
  14. 'sfx' => "", //Don’t know what it means
  15. )
  16. );
  17. $test->add_files("src/archive.php");
  18. $test->add_files("/App");
  19. $test->create_archive();
  20. $test->download_file();
    //If you don’t write this line, the data will only be stored in memory Inside
  21. //The following code is to decompress
  22. $test = new tar_file("archives/test.tar");
  23. $test- >set_options(array('inmemory' => 0));
  24. $test->extract_files();
  25. ?> >We hope that this code example introduced in this article can help us further understand the meaning of PHP compressed folders.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446142.htmlTechArticleHowever, there is no function for folder operations in the zlib library (of course, we can also write one ourselves, but this is too trouble), we can go online and download some ready-made books written by our ancestors...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!