How To Create Zip File In Codeigniter




Codeigniter Me Zip File Kaise Create Kare-



Steps-

1-create a Sonu.php controller in Controller Folder -



defined('BASEPATH') OR exit('No direct script access allowed');



class Sonu extends CI_Controller {



public function index()

{

$this->load->view('form');

$this->load->helper('captcha');



$this->load->library('zip');//step1-load the zip helper

$name = 'mydata1.txt';//step2-enter file name here

$data = 'welcome here how are u bro i am new in php please help me to learn more things about php help me bro';//step3-enter the contant which you want to add in file



$this->zip->add_data($name, $data);



// Write the zip file to a folder on your server. Name it "my_backup.zip"

$this->zip->archive('/path/to/directory/my_backup.zip');



// Download the file to your desktop. Name it "my_backup.zip"

$this->zip->download('my_backup.zip');



}

}





Multiple File Kaise Create Kare-How to create multiple files-

$name1 = 'mydata2.txt';

$data1 = 'Another Data String!';

$this->zip->add_data($name1, $data1);




Ya fir aap array ka use karke be multiple file create kar sakte ho zip file me-


$data = array(

        'mydata1.txt' => 'A Data String!',

        'mydata2.txt' => 'Another Data String!'

);



$this->zip->add_data($data);








How To Compress Data In Subdomain Folder-files ko Subfolder ke Ander kaise Generate Kare-

$name = 'gajabwap/my_bio.txt';

$data = 'I was born in an elevator...';



$this->zip->add_data($name, $data);


Aap is code ka use karke easily zip file me subfolder create kar sakte ho


Thank You


Previous
Next Post »
Thanks for your comment