我在内存中创建了多个 PDF 文件流。我可以从这些流中创建一个 zip 文件吗?如果可以,如何创建?我想为用户提供我的文件的下载 zip,而不在服务器上创建任何文件。
ZipArchive仅在运行 addFile
时显示文件名。
最佳答案
我最终找到了解决方案 here :
与此处给出的解决方案类似,我使用了 phpmyadmin 中的类如下:
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename='whatever.zip'");
$zip = new ZipFile;
foreach($pdfs as $idx => $content) {
$zip->addFile($content, "file$idx.pdf");
}
file_put_contents("php://output", $zip->file());
https://stackoverflow.com/questions/49192824/
相关文章:
python-sphinx - 如何在 python-sphinx 中突出显示文本?
hibernate - QueryDSL - 仅比较 dateTime 中的日期
react-native - react 导航 : stack navigator with tab
php - 错误:[8] PDO::__construct():发送 5 个字节失败,errno=3
r - tcltk 对话框出现在 RStudio/Shiny Windows 下
python - 模块 'site' 没有属性 'getusersitepackages'
kubernetes - 是否可以在同一端口上使用 nodeport 类型的 2 个不同 names