controllers/VehiculoController.php
/**
     * Updates an existing Vehiculo model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param string $id
     * @return mixed
     */
Updates an existing Vehiculo model.
If update is successful, the browser will be redirected to the 'view' page.
@param string $id
@return mixed
Updates an existing Vehiculo model . If update is successful the browser will be redirected to the ' view ' page . @param string $id @return mixed
public function actionUpdate($id)
    {
        $model = $this->findModel($id);
        $actual_image = $model->IMG_CARNET;
        if ($model->load(Yii::$app->request->post())) {
            $image= UploadedFile::getInstance($model, 'file');
            if(!empty($image) && $image->size !== 0) {
                $model->file = UploadedFile::getInstance($model, 'file');
                $model->file->saveAs('carnet/' . $model->PLACA_CHUTO . '.' . $model->file->extension);
                $model->IMG_CARNET = 'carnet/' . $model->PLACA_CHUTO . '.' . $model->file->extension;
            }else
                $model->IMG_CARNET = $actual_image;
            $model->save(false);
            return $this->redirect(['view', 'id' => $model->ID]);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ actual_image = $ model -> IMG_CARNET ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ image = UploadedFile :: getInstance ( $ model , 'file' ) ; if ( ! empty ( $ image ) && $ image -> size !== 0 ) { $ model -> file = UploadedFile :: getInstance ( $ model , 'file' ) ; $ model -> file -> saveAs ( 'carnet/' . $ model -> PLACA_CHUTO . '.' . $ model -> file -> extension ) ; $ model -> IMG_CARNET = 'carnet/' . $ model -> PLACA_CHUTO . '.' . $ model -> file -> extension ; } else $ model -> IMG_CARNET = $ actual_image ; $ model -> save ( false ) ; return $ this -> redirect ( [ 'view' , 'id' => $ model -> ID ] ) ; } else { return $ this -> render ( 'update' , [ 'model' => $ model , ] ) ; } }
Updates an existing Vehiculo model.
Updates an existing Vehiculo model .