CakePHP:Creare un file zip con ZipArchive
Versione del 26 apr 2020 alle 21:54 di Andrea (discussione | contributi) (Creata pagina con "← Torna a CakePHP Category:CakePHP <pre> $zip = new \ZipArchive(); $file_path = \Lib\FileLib::getTmpFolder( true ) . \Lib\MiscLib::randomID('tmp').'.zip'...")
$zip = new \ZipArchive(); $file_path = \Lib\FileLib::getTmpFolder( true ) . \Lib\MiscLib::randomID('tmp').'.zip'; if( $zip->open( $file_path, \ZipArchive::CREATE ) !== TRUE ) exit("cannot open <$file_path>\n"); $report_title = 'export.zip'; foreach( $collezione as $filepath ) { $zip->addFile( $filepath, $filename.'.pdf' ); } $zip->close();