How to Create ZIP using CodeIgniter?
Step1- Create a Folder(Name ZIP) in your Application Folder
(Example: C:\wamp\www\mms\zip)
Step2- Create a function in a Controller.
Public function gen_zip(){
$zipfolder=”Archive.zip";
$filename='file1”;
$data=”This is file1”;
$this->load->library('zip');
$this->zip->add_data($filename, $val);
$this->zip->archive($_SERVER['DOCUMENT_ROOT'].'/mms/zip/'.$zipfolder);
/*
$_SERVER['DOCUMENT_ROOT'] is Application Root Directory.
Here C:\wamp\www\ is Document Root.
*/
$filename='file2”;
$data=”This is file2”;
$this->load->library('zip');
$this->zip->add_data($filename, $val);
$this->zip->archive($_SERVER['DOCUMENT_ROOT'].'/mms/zip/'.$zipfolder);
/*
$_SERVER['DOCUMENT_ROOT'] is Application Root Directory.
Here C:\wamp\www\ is Document Root.
*/
}
I hope that it will be help you.
No comments:
Post a Comment