/** * 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())) { $upload_file = $model->uploadFile(); var_dump($model->validate()); if ($model->validate()) { if ($model->save()) { if ($upload_file !== false) { $path = $model->getUploadedFile(); $upload_file->saveAs($path); } return $this->redirect(['index']); } } } return $this->render('create', ['model' => $model]); }