I have multiples files to be compressed into one unique file (zip), but it seems that it creates a new file everytime the loop restart, how do I do that? there is no enough documentation about this, here is my code:
$file1 = "test1.xls";
$files2 = array(
"test2.xls", "test3.xls"
);
$filter = new Zend_Filter_Compress(array(
'adapter' => 'Zip',
'options' => array(
'archive' => BASE_PATH .'/public/' . $this->configuracoes->get('media') . '/temp/zipped'.date('d-m-Y-H-i-s').'.zip'
)
));
$compress = $filter->filter($file1);
foreach($files2 as $file){
$compress = $filter->filter($file);
}
This only result a zip with test3.xls inside.
Worth looking at this link, seems to be the same answer where you open the zip, add files, then close it outside the loop.
An old question but I found this looking for something similar.
You can pass a directory to the filter
function and it will recursively add all files within that directory.
i.e
$compress = $filter->filter('/path/to/directory/');