old avatar fix
This commit is contained in:
parent
4404c6ea42
commit
c1f63a49f2
2 changed files with 12 additions and 0 deletions
|
@ -1661,6 +1661,10 @@
|
||||||
{
|
{
|
||||||
"type": "ADD",
|
"type": "ADD",
|
||||||
"change": "Added avatar uploading (background uploads soon)."
|
"change": "Added avatar uploading (background uploads soon)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIX",
|
||||||
|
"change": "Fixed old avatars not getting deleted."
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -245,6 +245,7 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
|
||||||
// Set path variables
|
// Set path variables
|
||||||
$filepath = ROOT .'content/images/user/';
|
$filepath = ROOT .'content/images/user/';
|
||||||
$filename = $filepath .'avatar_'. Session::$userId;
|
$filename = $filepath .'avatar_'. Session::$userId;
|
||||||
|
$currfile = !empty($_AVA = Users::getUser(Session::$userId)['userData']['userAvatar']) ? $_AVA : null;
|
||||||
|
|
||||||
// Check if $_FILES is set
|
// Check if $_FILES is set
|
||||||
if(!isset($_FILES['avatar']) && empty($_FILES['avatar'])) {
|
if(!isset($_FILES['avatar']) && empty($_FILES['avatar'])) {
|
||||||
|
@ -393,6 +394,13 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete old avatar
|
||||||
|
if($currfile && file_exists($currfile)) {
|
||||||
|
|
||||||
|
unlink($filepath . $currfile);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Append extension to filename
|
// Append extension to filename
|
||||||
$filename .= image_type_to_extension($metadata[2]);
|
$filename .= image_type_to_extension($metadata[2]);
|
||||||
|
|
||||||
|
|
Reference in a new issue