I tried to add my pictures, which uploaded by users, into a zip file. so, that user can download this file. The problem is when I download this zip file, it contains lots of filename (as I expect). But when I open this zip, it show me error “C:....ata\Local\Temp\my_photo.zip: Unexpected end of archive”
Each picture has size but CRC32 is 00000000 Here is the code:
$this->load->library('zip');
$this->zip->clear_data();
foreach ($row as $ar){
$file_relative_path = $ar->filepath;
if(file_exists($file_relative_path)){
$this->zip->add_data($this->_getFileName($file_relative_path),file_get_contents($file_relative_path));
}
}
$this->zip->download('my_photo.zip');