【问题标题】:How to create a zipfile with child zipFiles in php如何在 php 中创建带有子 zip 文件的 zip 文件
【发布时间】:2023-03-12 10:51:01
【问题描述】:

我需要创建一个包含子 zipFiles 的 zipFile:

> folder
  - file1.zip
  - file2.zip

我想获取一个包含文件夹中所有 zip 文件的 zip 文件。

$dir = "path/to/my/dir";
$finder = new Finder();
$zip = new \ZipArchive();

/***** I create a empty zip file ****/
$filesystem->dumpFile("$dir/delivrables.zip",'');

if($zip->open('delivrables.zip', ZipArchive::CREATE) === TRUE) {
    foreach ($finder->in($dir) as $file) { 
        $zip->addFile($file->getPath(), $file->getFilename());
    }
}

我没有收到错误,但我无法提取 zip 文件。

【问题讨论】:

  • 您收到错误消息了吗?
  • 你的问题究竟是什么?

标签: php symfony


【解决方案1】:

您可以使用与创建包含图像、文档等的 zip 文件相同的方式创建包含 zip 文件的 zip 文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-28
    • 2013-09-25
    • 1970-01-01
    • 2017-01-17
    • 2017-01-22
    • 2016-02-06
    • 2013-07-10
    • 1970-01-01
    相关资源
    最近更新 更多