使用zip文件下载图像


Download Images with zip File

>我正在从API生成动态图像。

单击按钮后,我想下载一个带有图像的zip文件。

我尝试了许多解决方案,但仍然无法下载带有图像的zip文件

$zip = new ZipArchive();
$zip_name = time().".zip"; // Zip name
$zip->open($zip_name,  ZipArchive::CREATE);
foreach ($files as $file) {
    echo $path = "uploadpdf/".$file;
      if(file_exists($path)){
          $zip->addFromString(basename($path),file_get_contents($path));  
      }else {
          echo"file does not exist";
      }
}
$zip->close()