public function folderdownload(){
try{
$this->load->library('zip');
$this->load->helper('file');
$where = array(
'file_perm_id'=>$this->input->post('id'));
$this->load->model('fetch_model');
$file_path = $this->fetch_model->getalldata($this->folderpath,$this->master,$where);
$path = @@$file_path[0]->folder_path ;
$files = get_filenames($path);
// when i used print_r($files); to verify that i can see the files i can see it from here
foreach($files as $f){
if (is_file($path . $f))
$this->zip->add_data($f, file_get_contents($path . $f));
}
ob_end_clean();
$this->zip->download(date('m-d-Y'));
}catch(Exception $e){
echo 'Caught exception: ', $e->getMessage(), "\n";
}
}
I have this controller that once the use click the download button it download all the files within the folder but when I open it it says that the archieve is either unknown format or damaged. please help hoiw can I download files and zip it this is in codeigniter. thanks anyone
Your zip file creation is having issue.
I would suggest you to first check you content availability and then create zip file and at last download it.
To create ZIP file