From 0b7be053a43014ff38db1be9fb5f7ebef80d9c8f Mon Sep 17 00:00:00 2001 From: "Alfonso Saavedra \"Son Link" Date: Thu, 7 Nov 2024 17:11:28 +0100 Subject: [PATCH] Fix remove avatar if previous version isn't exists --- app/Controllers/Dashboard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/Dashboard.php b/app/Controllers/Dashboard.php index 7e72cbc..0075366 100644 --- a/app/Controllers/Dashboard.php +++ b/app/Controllers/Dashboard.php @@ -93,7 +93,7 @@ class Dashboard extends BaseController $userData = $this->usersModel->getUser($this->session->username); $avatar = FCPATH . '/img/users/'. $userData->img; $oldAvatarFile = new \CodeIgniter\Files\File($avatar); - if ($oldAvatarFile->getExtension() != $ext) unlink($avatar); + if ($oldAvatarFile->getExtension() != $ext && file_exists($avatar)) unlink($avatar); $filename = "{$this->session->username}.$ext"; $move = $file->move(FCPATH . '/img/users/', $filename, true);