Fix remove avatar if previous version isn't exists

This commit is contained in:
Alfonso Saavedra "Son Link" 2024-11-07 17:11:28 +01:00
parent 2238fc39af
commit 0b7be053a4
No known key found for this signature in database
GPG Key ID: D3594BCF897F74D8
1 changed files with 1 additions and 1 deletions

View File

@ -93,7 +93,7 @@ class Dashboard extends BaseController
$userData = $this->usersModel->getUser($this->session->username); $userData = $this->usersModel->getUser($this->session->username);
$avatar = FCPATH . '/img/users/'. $userData->img; $avatar = FCPATH . '/img/users/'. $userData->img;
$oldAvatarFile = new \CodeIgniter\Files\File($avatar); $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"; $filename = "{$this->session->username}.$ext";
$move = $file->move(FCPATH . '/img/users/', $filename, true); $move = $file->move(FCPATH . '/img/users/', $filename, true);