I am using a Zipper package for making zip files out of API fetched PDF's. Zipping works fine but I would like to delete PDF files that were zipped.
$pdf_summary_filename = public_path() . $path . uniqid() . '_summary.pdf';
PDF::loadView('pdf.summary', $pdf_data)->save($pdf_summary_filename);
$zipper->make($zip_filename)->add($pdf_summary_filename);
File::cleanDirectory(public_path() . '/user_downloads');
I am using this code, however, I think that cleanDirectory()
gets called before the zipping finishes, and I see no zip generated. If I comment out the last line, I get both the zip file as well as PDF's in /user_downloads
.
How can I wait for the zipper to finish zipping?
UPDATE: You can try below code:
$flgFile = $zipper->make($zip_filename)->add($pdf_summary_filename);
if($flgFile){
File::cleanDirectory(public_path() . '/user_downloads');
}
This may help you better!