public function actionCreate() { $model = new District(); if ($model->load(Yii::$app->request->post())) { $image = $model->uploadImage(); if ($model->save()) { if ($image !== false) { $path = $model->getImageFile(); $image->saveAs($path); $this->saveThumb($model); } return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('create', ['model' => $model]); }