예제 #1
0
 function run()
 {
     if (isset($_FILES)) {
         $model = Yii::createObject(['class' => FileUploadModel::className(), 'module' => $this->module, 'storage' => $this->storage]);
         if ($model->upload()) {
             return $model->getResponse();
         } else {
             return ['error' => 'Unable to save file'];
         }
     }
 }
예제 #2
0
파일: Post.php 프로젝트: jarrus90/yii2-blog
 public function saveImage($image, $override = true)
 {
     $model = Yii::createObject(['class' => FileUploadModel::className(), 'module' => $this->module->getModule('redactor'), 'storage' => $this->storage, 'file' => $image]);
     if ($model->upload()) {
         if ($override) {
             $this->deleteImage();
         }
         $result = $model->getResponse();
         return $result['filename'];
     } else {
         return false;
     }
 }