I created a new disk driver to save in the public folder like you suggested
'report_upload' => [
'driver' => 'local',
'root' => public_path() . '/reports',
],
And now I save those files in public/reports so all the files are there now (these are created using jobs), after that I have another Job to create a zip and delete the files, like this
$zip = new ZipArchive;
if (true === ($zip->open('ReportesTodos.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE))) {
foreach (Storage::disk('report_upload')->files() as $name) {
$name = basename($name);
$zip->addFile(public_path('reports\' . $name), $name);
}
$zip->close();
}
// download zip
// return response()->download(public_path('ReportesTodos.zip'), 'ReportesTodos.zip');
if (file_exists(public_path('ReportesTodos.zip'))) {
foreach (Storage::disk('report_upload')->files() as $name) {
$name = basename($name);
Storage::disk('report_upload')->delete($name);
}
}
Would this be the correct way to remove the files ? What would you recommend, just download the zip after the jobs are all done or notify the user to download it from a separate page? I don't have emails setup on this project on the server in order to send it that way.