new ZipArchive is not working in cakephp it showing
error :=Class
'App\Controller\ZipArchive' not found
This is what I have tried so far:
$fl_name = array('1.pdf', '2.pdf');
$zipname = 'file.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($fl_name as $file){
$zip->addFile($file);
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=' . $zipname);
header('Content-Length: ' . filesize($zipname));
readfile($zipname);