public function actionUpload()
 {
     if ($_GET['id']) {
         $id = intval($_GET['id']);
     }
     if ($_GET['unixtime']) {
         $unixtime = intval($_GET['unixtime']);
     }
     $folder = Yii::getPathOfAlias('webroot') . '/uploads/c' . Company::getId();
     if ($id) {
         $folder .= '/' . $id . '/';
     } else {
         $folder .= '/temp/' . $unixtime . '/';
     }
     $result = Tools::uploadMaterials($folder);
     echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
     if ($id && $result['success'] && User::model()->isCustomer()) {
         EventHelper::materialsAdded($id);
     }
 }
 public function actionUpload()
 {
     Yii::import("ext.EAjaxUpload.qqFileUploader");
     // --- кампании
     $c_id = Campaign::getId();
     if ($c_id) {
         $folder = 'uploads/c' . $c_id . '/' . $_GET['id'] . '/';
     } else {
         $folder = 'uploads/' . $_GET['id'] . '/';
     }
     // ---
     if (!file_exists($folder)) {
         mkdir($folder, 0777);
     }
     $config['allowedExtensions'] = array('png', 'jpg', 'jpeg', 'gif', 'txt', 'doc', 'docx');
     $config['disAllowedExtensions'] = array("exe");
     $sizeLimit = 10 * 1024 * 1024;
     // maximum file size in bytes
     $uploader = new qqFileUploader($config, $sizeLimit);
     if (!User::model()->isAdmin()) {
         $_GET['qqfile'] = '#pre#' . $_GET['qqfile'];
     }
     $result = $uploader->handleUpload($folder, true);
     if ($result['success'] && User::model()->isCustomer()) {
         EventHelper::materialsAdded($_GET['id']);
     }
     $result['fileSize'] = filesize($folder . $result['filename']);
     //GETTING FILE SIZE
     $result['fileName'] = $result['filename'];
     //GETTING FILE NAME
     chmod($folder . $result['fileName'], 0666);
     echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
 }