Yii 1.0 Create Zip file

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(); 
}