dimanche 28 juin 2015

update a record without removing the uploaded file in yii

HELP PLEASE

I need to UPDATE record with out changing or deleting filename(i mean file)

here is my actionCreate How i can write update ??

    public function actionCreate() {
    $model = new Page;
    if (isset($_POST['Page'])) {
        $model->attributes = $_POST['Page'];
        $model->filename = CUploadedFile::getInstance($model, 'filename');
        if ($model->save()) {
            if ($model->filename !== null) {
                $dest = Yii::getPathOfAlias('application.uploads');
                $model->filename->saveAs($dest . '/' . $model->filename->name);

                $model->save();
            }
            $this->redirect(array('view', 'id' => $model->id));
        }
    }
    $this->render('create', array(
        'model' => $model,
    ));
}

So Please can anyone find a solution .... Thanks All

Aucun commentaire:

Enregistrer un commentaire