public function addDropboxFiles($uploadsession) { $files = $this->tmpFiles; // $existFiles = count($this->images); // $availableFiles = $this->maxFiles - $existFiles; $cnt = 0; // if($files){ if(Yii::app()->session->itemAt($uploadsession)){ // $folder='uploads'. DIRECTORY_SEPARATOR .'tmp'. DIRECTORY_SEPARATOR; $folder = Yii::getPathOfAlias(Yii::app()->params['storeImages']['tmp']).DIRECTORY_SEPARATOR; $dataSession = Yii::app()->session->itemAt($uploadsession); // foreach($files as $fileUploadName){ if(is_array($dataSession)){ foreach($dataSession as $key => $value){ // if($fileUploadName == $key){ if(@file_exists($folder.$value )) { //if($cnt >= $availableFiles) // break 2; /* $file = $folder.$value; $ext = pathinfo($folder.$value, PATHINFO_EXTENSION); $base = md5(rand(1000,4000)); $unique = $base.'_article'; $suffix = 1; while (file_exists($this->getFileFolder() . $unique . $ext)){ $unique = $base.'_'.$suffix; $suffix++; } $filename = $unique . '.' . $ext; $fullPath = $this->getFileFolder() . $filename;*/ $fullPath = $this->getFileFolder().$value; if (copy($folder.$value, $fullPath)) { unlink($folder.$value); $image = new ArticleImages(); $image->article = $this->getPrimaryKey(); $image->filename = $value; $image->realname = $key; /* Yii::import('ext.phpthumb.PhpThumbFactory'); $thumb = PhpThumbFactory::create($fullPath); $thumb->setOptions(array('jpegQuality'=>100)); $thumb->resize(1000)->save($fullPath); */ $image->save(); $cnt++; } else { // throw new CHttpException(404, Yii::t('Site', 'Cannot copy file to folder.')); } } // } } } // } } // } }