首页 > 解决方案 > N 不支持多磁盘 zip 存档

问题描述

我想使用 php zipArchive 将文件下载到 zip,但我收到此错误“不支持 N 多磁盘 zip 存档”。

标签: phplaravel

解决方案


$file_names是您要在 zip 中添加的文件数组

 function zipFile($file_names,$archive_file_name)
{
    $zip = new ZipArchive();
    //create the file and throw the error if unsuccessful
    if ($zip->open($archive_file_name, ZIPARCHIVE::OVERWRITE )!==TRUE) {

    }

    //add each files of $file_name array to archive
    foreach($file_names as $files)
    {
    //  $zip->addFile($files,$files);
        $zip->addFromString(basename($files),  file_get_contents($files));
    }
    $zip->close();


}

推荐阅读