/** * Creates a new Books model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Books(); if ($model->load(Yii::$app->request->post())) { $image = $model->uploadImage(); if ($image !== false) { $path = $model->getImageFile(); $image->saveAs($path); } // if ($path = $model->upload()) { // $model->preview_image = $path; // } $model->save(); return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model, 'authors' => Authors::getAuthorsList()]); } }