hi my goal is to create zip file and download it, working okay on local server but giving problem on Cpanel when i hit download button
$fileEntry = FileEntry::with('childEntriesRecursive')->where('shared_id', $shared_id)->notExpired()->firstOrFail();
abort_if(!static::accessCheck($fileEntry), 404);
$zip_file = str_replace(' ', '_', $fileEntry->name).'.zip';
$zip = new ZipArchive();
$zip->open(public_path($zip_file), ZipArchive::CREATE | ZipArchive::OVERWRITE);
foreach ($fileEntry->childEntriesRecursive as $key => $file) {
$getFile = storage_path('app/public/'.$file->path);
if (file_exists($getFile) && is_file($getFile)){
echo $file->name;
$zip->addFile(storage_path('app/public/'.$file->path), $file->name);
}
}
$zip->close();
return response()->download($zip_file, basename($zip_file))->deleteFileAfterSend(true);