Hello everyone,
i made a project where i can upload files with the crud, and this works perfectly, the only problem is that when i create a new post with a file , but later try to edit the post and update it, the file path has been removed again.
How can i prevent the model from resetting the file url column to null?
i tried this, but it is not working.
if (isset($_POST['Referenties'])) {
$model->attributes = $_POST['Referenties'];
$model->logo = isset($model->logo) ? CUploadedFile::getInstance($model, 'logo') : null;
if ($model->save()) {
if (isset($model->logo)) {
$model->logo->saveAs(Yii::getPathOfAlias('webroot') . '/files/' . $model->logo);
}
$this->redirect(array('view', 'id' => $model->id));
}
}
thanks in advance.