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']; } } }
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; } }