diff --git a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php index 74d2f0c1..20bef34d 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/DownloadBookingDocumentLogic.php @@ -47,15 +47,20 @@ class DownloadBookingDocumentLogic $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), $booking->created_at->format('d_m_Y') . '_' . $booking->marking . '.pdf'); } - $zip->close(); + if ($zip->close() === false) { + exit("Error creating ZIP file"); + }; - header('Content-Type: application/zip'); - header('Content-Length: ' . filesize($attachment)); + if (file_exists($attachment)) { - // download zip - readfile($attachment); + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename='.$attachment.'.zip'); + header('Content-Length: ' . filesize($attachment)); + readfile($attachment); + } else { + exit("Could not find Zip file to download"); + } - // delete after download unlink($attachment); }