/** * Creates a new Files model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Files(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id, 'user_id' => $model->user_id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Files(); if ($model->load(Yii::$app->request->post())) { if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } return $this->render('create', array('model' => $model)); }
/** * Creates a new Files model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Files(); if ($model->load(Yii::$app->request->post())) { // process uploaded image file instance $file = $model->uploadImage(); if ($model->save()) { // upload only if valid uploaded file instance found if ($file !== false) { $path = $model->getImageFile(); $file->saveAs($path); } Yii::$app->session->setFlash("file-success", '<i class="fa fa-check"></i> Arquivo anexado com sucesso!'); return $this->redirect(['/solicitation/view', 'id' => $model->solicitation_id, '#' => 'checklist']); } else { // error in saving model } } return $this->render('create', ['model' => $model]); }