public function actionDownload($name, $id)
 {
     if ($name !== null) {
         $userFilePath = Yii::getPathOfAlias('site.files') . '/workshops/' . $id;
         $userFilePath .= "/" . $name;
         if (!FileHelper::outputFile($name, $userFilePath)) {
             throw new CHttpException(404, 'File not found');
         }
     }
 }
 public function actionDownloadPortfolioZip()
 {
     if (isset($_POST) && isset($_POST['stu_job_id']) && !empty($_POST['stu_job_id'])) {
         $criteria = new CDbCriteria();
         $criteria->addInCondition('stu_job_id', $_POST['stu_job_id']);
         $criteria->select = 'stu_job_id,student_id,stu_job_id,first_name,last_name,portfolio_file';
         $selectedJobs = ViewStudentJobTitle::model()->findAll($criteria);
         if ($selectedJobs != null) {
             $tmpZipFile = tempnam(sys_get_temp_dir(), 'zip');
             //FileHelper::getFilePath(Yii::getPathOfAlias('site.files').'/resumes/temp/zip/',true);
             $zip = new ZipArchive();
             if ($zip->open($tmpZipFile, ZipArchive::OVERWRITE) === true) {
                 foreach ($selectedJobs as $key => $job) {
                     $student_id = $job['student_id'];
                     $stu_job_id = $job['stu_job_id'];
                     $first_name = $job['first_name'];
                     $last_name = $job['last_name'];
                     $name = $job['portfolio_file'];
                     if (empty($name)) {
                         continue;
                     }
                     $ext = CFileHelper::getExtension($name);
                     $userFilezipName = $first_name . $last_name . '_pf_jobtitle_' . $stu_job_id . '.' . $ext;
                     if ($name !== null) {
                         $userFilePath = Yii::getPathOfAlias('site.files') . '/resumes/' . $student_id;
                         $userFilePath .= '/' . $name;
                         if (file_exists($userFilePath)) {
                             $zip->addFile($userFilePath, $userFilezipName);
                         }
                     }
                 }
                 if ($zip->close()) {
                     if (!FileHelper::outputFile('portfoliosZip' . Randomness::randomString() . '.zip', $tmpZipFile)) {
                         throw new CHttpException(404, 'Download zip failed');
                     }
                 }
             }
         }
         die;
     } else {
         throw new CHttpException(400, "Unable to find the selected filesll");
     }
 }