/** * Creates a new MEMBERS model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new MEMBERS(); if ($model->load(Yii::$app->request->post())) { //Call model's uploadImage method $image = $model->uploadImage(); // Save the data to the DB and save the image onto specified path if ($model->save()) { // upload only if valid uploaded file instance found if ($image !== false) { $path = $model->getImageFile(); $image->saveAs($path); } return $this->redirect(['view', 'id' => $model->MEMBER_ID]); } else { // error in saving model } } else { return $this->render('create', ['model' => $model]); } }