コード例 #1
0
ファイル: FilesController.php プロジェクト: phprocks/cadastro
 /**
  * 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]);
 }