/** * Creates a new Resource model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($type) { $model = new Resource(); $model->type = $type; if ($model->load(Yii::$app->request->post())) { if (isset($_FILES) && $_FILES) { $model->imageFile = UploadedFile::getInstance($model, 'imageFile'); if ($model->imageFile) { $model->upload(); } } if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('create', ['model' => $model]); }