/** * Creates a new UserFile model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UserFile(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->ID]); } else { return $this->render('create', ['model' => $model]); } }
public function actionUpload() { $model = new UserFile(); if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $model->USER_ID = Yii::$app->user->identity->username; $exportFile = $model->uploadFile(); if ($model->save()) { //upload only if valid uploaded file instance found if ($exportFile !== false) { $path = $model->getImageFile(); $exportFile->saveAs($path); return $this->redirect(['index', 'id' => $model->FILE_NM]); } } } } }