Monday, May 7, 2012

Create zip file in yii

Create Zip Files Using PHP

I added the source code to create a zip file in yii.
public function actionCreatefile($filename,$filelist)
{
$zip=new ZipArchive();
$destination=DIRDetails."/filename.zip";
if($zip->open($destination,ZIPARCHIVE::CREATE) !== true) {
   return false;
}

foreach($filelist as $thefile)
{
   $random=rand(11111,99999);
   $filename=$random.$thefile;      
   $zip->addFile($thefile->tempname,$filename);
}
$zip->close(); 

}  

0 comments:

Post a Comment