1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-06 15:45:34 +02:00

[ticket/13980] Uploaded avatar not removed when new is uploaded

Remove the previously uploaded avatar when a new one with a different
extension is uploaded

PHPBB3-13980
This commit is contained in:
javiexin 2015-07-03 19:40:09 +02:00
parent 558d604d83
commit 352e995674

View File

@ -161,6 +161,16 @@ class upload extends \phpbb\avatar\driver\driver
return false;
}
$ext = substr(strrchr($row['avatar'], '.'), 1);
if ($ext && $ext !== $file->get('extension'))
{
$filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $row['id'] . '.' . $ext;
if (file_exists($filename))
{
@unlink($filename);
}
}
return array(
'avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'),
'avatar_width' => $file->get('width'),