laravel - ZipArchive 的路径在哪里?
问题描述
我正在尝试通过将文件添加到 zip 并在下载时返回响应来进行文件的多次下载。但是zip的路径是什么?
use Illuminate\Support\Facades\Response as FacadeResponse;
$pdfs = $request->get('check');
if (is_array($pdfs)) {
$zipname = "facturas.zip";
$zip = new \ZipArchive();
$zip->open($zipname, \ZipArchive::CREATE);
foreach ($pdfs as $pdf) {
$zip->addFile($pdf);
}
$zip->close();
$headers = array(
'content-type' => 'application/zip',
'Content-disposition:' => 'attachment; filename=filename.zip'
);
$path = ???
return FacadeResponse::download($path, $zipname, $headers);
}
我已经尝试过使用 base_path。public_path, app_path ...但没有一个有效。
解决方案
推荐阅读
- javascript - 按 Key 值将 JSON 对象过滤为字符串数组
- process - 有没有办法在独立进程中执行 Rust 函数?
- regex - 修改正则表达式以不允许空格
- python - 如何修复我编写的用于查找被阻止呼叫数量的计数器?
- python-3.x - Python Multiprocessing :: 在满足退出条件时产生孩子并杀死所有孩子
- string - Flutter:用文本填充文本字段(重复字符串)
- machine-learning - 时间序列预测:每周与每日预测
- java - 为什么在明显使用未使用的方法时违反 PMD
- sinatra - 如何在多线程 Unicorn Sinatra 服务器中仅在一个线程中运行函数?
- r - tidyr replace NA 似乎不适用于日期向量