controllers/JuegosController.php
/**
     * Creates a new Juegos model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Juegos model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Juegos model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new Juegos();
        if ($model->load(Yii::$app->request->post())) {
            $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
            if ($model->upload() && $model->save()) {
                $model->imageFile->saveAs('uploads/juegos/' . $model->imagen);
                return $this->redirect(['view', 'id' => $model->id]);
            }
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
public function actionCreate ( ) { $ model = new Juegos ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> imageFile = UploadedFile :: getInstance ( $ model , 'imageFile' ) ; if ( $ model -> upload ( ) && $ model -> save ( ) ) { $ model -> imageFile -> saveAs ( 'uploads/juegos/' . $ model -> imagen ) ; return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } } return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; }
Creates a new Juegos model.
Creates a new Juegos model .
// if($model->save()){ // el archivo se subió exitosamente // }