aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaviexin <javiexin@gmail.com>2015-07-03 19:40:09 +0200
committerjaviexin <javiexin@gmail.com>2015-07-03 19:40:09 +0200
commit352e9956748b29672f71762ae18bec331a47f337 (patch)
tree7a16759950b71978e2256a951f2db30ff231dedd
parent558d604d83fd5ded2edc854a9944ad0d1188e2e5 (diff)
downloadforums-352e9956748b29672f71762ae18bec331a47f337.tar
forums-352e9956748b29672f71762ae18bec331a47f337.tar.gz
forums-352e9956748b29672f71762ae18bec331a47f337.tar.bz2
forums-352e9956748b29672f71762ae18bec331a47f337.tar.xz
forums-352e9956748b29672f71762ae18bec331a47f337.zip
[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
-rw-r--r--phpBB/phpbb/avatar/driver/upload.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php
index ee36243844..eae96cd794 100644
--- a/phpBB/phpbb/avatar/driver/upload.php
+++ b/phpBB/phpbb/avatar/driver/upload.php
@@ -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'),