Welcome Guest, Not a member yet? Register   Sign In
ZIp library problem
#1

[eluser]Unknown[/eluser]
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:

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');

Please help
#2

[eluser]Pedro Correia[/eluser]
I was having the same problem and it was caused by having a couple of var_dump used for debugging in the method that creates the zip archive.

The zip library documentation says:
Code:
Note:  Do not display any data in the controller in which you call this function since it sends various server headers that cause the download to happen and the file to be treated as binary.




Theme © iAndrew 2016 - Forum software by © MyBB