/** * Upload file, save to storage and db * @return bool */ public function actionUpload() { $model = new FileUpload(); $model->setAttributes(Yii::$app->request->post()); if ($model->save()) { return true; } return json_encode(['error' => 'Model save errors: ' . json_encode($model->getErrors())]); }