Files are getting zipped..but once i extracting the zip file, the result is single file..not a multiple file.How to zip multiple file using zend filter(Zip)..?
Here is my code..
//zip part
$filter = new Compress(array(
'adapter' => 'Zip',
'options' => array(
'archive' => TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR. "download" . DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id.'.zip'
)
));
$file_list = scandir(TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR. "download". DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id);
if(count($file_list) >2){
foreach ($file_list as $file) {
if (in_array($file, array(".",".."))) continue;
$filter->filter(TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR. "download". DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id . DIRECTORY_SEPARATOR . $file);
}
}
//zip end
Every $filter->filter(…)
invocation creates a new archive that contains only one file and the existing archive with the previous file gets overwritten. Solution:
$filter = new Compress([
'adapter' => 'Zip',
'options' => [
'archive' => TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR . 'download'
. DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id . '.zip'
]
]);
// assuming you _can_ create archive from the whole directory
$filter->filter(TEMP_UPLOAD_PATH . DIRECTORY_SEPARATOR . 'download'
. DIRECTORY_SEPARATOR . $result['downloadResult']->r_download_id);