search
Homephp教程php手册PHP压缩文件夹的具体实现方法

PHP压缩文件夹的具体实现方法

Jun 13, 2016 am 11:09 AM
phpzlibspecificfunctioncompressionaccomplishrightusoperatefoldermethodof

不过zlib 库中没有对文件夹操作的函数(当然,我们也可以自己写一个,但这样太麻烦),我们可以去网上下载一些现成的,由先辈们写的,扩展了 zlib 函数库的工具。

PHP压缩文件夹的具体实现代码:

  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, //不在内存压缩.
    而是直接存放到磁盘.如果要压缩下载,则可以选择为1  
  8. ‘recurse’ => 1, //是否压缩子目录,
    resurse,递归的意思?  
  9. ’storepaths’ => 1, //是否存储目录结构,我选是。  
  10. ‘overwrite’ => 1, //是否覆盖  
  11. ‘prepend’ => "", //未知  
  12. ‘followlinks’ => 0, //未知  
  13. ‘method’ => 1, //未知  
  14. ’sfx’ => "", //不知道什么意思  
  15. )  
  16. );  
  17. $test->add_files("src/archive.php");  
  18. $test->add_files("/App");  
  19. $test->create_archive();  
  20. $test->download_file();
    //不写这一行,数据只存在内存里  
  21. //以下代码为解压  
  22. $test = new tar_file("archives/test.tar");  
  23. $test->set_options(array(’inmemory’ => 0));  
  24. $test->extract_files();  
  25. ?> 

希望通过本文介绍的这段代码示例可以帮助我们进一步了解PHP压缩文件夹的含义。


Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.