Welcome Guest, Not a member yet? Register   Sign In
How can i add multiple zip files created by CI itself in a single Zip file.
#1

[eluser]sherpa[/eluser]
I can create a single zip file with multiples files in it. But what i want is multiple zip files in a single zip created by CI itself.

My code goes like this. I just can't figure out where the problem is :


Code:
function getAll($id){
    
    $Contents         =  $this -> frontend -> DownloadFiles($id);
    $data =  array();
    
    
    $RecordCount = 0;
    for($RecordCount =  0; $RecordCount < count($Contents['keywords']);$RecordCount++)
    {
        $file_contents_title = $Contents['title'][$RecordCount])));
        $file_contents_desc =  $Contents['description'][$RecordCount])));
        $file_content_keywords =  $Contents['keywords'][$RecordCount];
        $file_content = $Contents['contents'][$RecordCount])));
        
        $data[url_title($file_contents_title). "_CONTENTS.txt"] =  $file_content;
        $data[url_title($file_contents_title). "_KEYWORDS.txt"] =  $file_content_keywords;
        $data[url_title($file_contents_title). "_DESCRIPTION.txt"] =  $file_contents_desc;
    }
    
        $this -> zip -> add_data($data);
        $zip_file = $this -> zip -> get_zip();
    
    
    $this->zip->download($Contents['filename'] . '.zip');
    }


Thnaks in advance.
#2

[eluser]sherpa[/eluser]
Solution for the Post :
for other's reference;





Code:
function getAll($id){
    
    $Contents         =  $this -> frontend -> DownloadFiles($id);
    

    $data =  array();
    
    
    $RecordCount = 0;
    for($RecordCount =  0; $RecordCount < count($Contents['keywords']['keywords']);$RecordCount++)
    {
        $file_contents_title =  $Contents['title'][$RecordCount];
        $file_contents_desc =   $Contents['description'][$RecordCount];
        $file_content_keywords =  $Contents['keywords'][$RecordCount];
        $file_content =  $file_contents_title . "\r\n\" .  $Contents['contents'][$RecordCount];
        
        
        $data=array(    
                    url_title($file_contents_title). "_CONTENTS.txt" =>$file_content,
                    url_title($file_contents_title). "_KEYWORDS.txt" => $file_content_keywords,
                    url_title($file_contents_title). "_DESCRIPTION.txt" => $file_contents_desc
                    );
        
                    
        $this -> zip -> add_data($data);
        $zip_file['data'][$RecordCount] = $this -> zip -> get_zip();
        $zip_file['filename'][$RecordCount] = url_title($file_contents_title). ".zip";
        $this -> zip -> clear_data();
        
    
    }
    
    for($i=0;$i<count($zip_file['data']);$i++)
    {
        $this -> zip -> add_data($zip_file['filename'][$i],$zip_file['data'][$i]);
    }
    
    
    $this->zip->download($Contents['filename'] . '.zip');
}




Theme © iAndrew 2016 - Forum software by © MyBB