/** * Creates a new Foto model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Foto(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->idFoto]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Foto model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Foto(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $imageName = $model->titutlo; $model->file = UploadedFile::getInstance($model, 'file'); $model->file->saveAS('uploads/' . $imageName . '.' . $model->file->extension); $model->link = 'uploads/' . $model->titutlo . '.' . $model->file->extension; $model->save(); return $this->redirect(['view', 'id' => $model->id_foto]); } else { return $this->render('create', ['model' => $model]); } }