/** * Creates a new Portfolio model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Portfolio(['scenario' => 'create']); if ($model->load(Yii::$app->request->post())) { $model->image = UploadedFile::getInstance($model, 'image'); if ($model->validate() && $model->save() && $model->image) { $model->image->saveAs(Yii::getAlias('@webroot/uploads/portfolio/' . $model->id . '.jpg')); return $this->redirect(['view', 'id' => $model->id]); } } return $this->render('create', ['model' => $model]); }