How to create and download zip file in codeigniter ?

/* create zip folder */

public function zip(){
$getImage = $this->cart_model->getImage();
$zip = new ZipArchive;
$auto = rand();
$file = date(“dmYhis”,strtotime(“Y:m:d H:i:s”)).$auto.’.zip’;
if ($zip->open(‘./download/’.$file, ZipArchive::CREATE)) {
foreach($getImage as $getImages){
$zip->addFile(‘./assets/upload/photos/’.$getImages->image, $getImages->image);
}
$zip->close();
$downloadFile = $file;
$download = Header(“Location:http://localhost/projectname/download/”.$downloadFile);
}
}

About Author

Leave a Reply

Your email address will not be published. Required fields are marked *

PAGE TOP
error

Enjoy this blog? Please spread the word :)

RSS
Follow by Email