mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
added this back, file extensions might change need to delete old pic
This commit is contained in:
@@ -126,7 +126,22 @@ var user = require('./../user.js'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.getUserField(req.user.uid, 'uploadedpicture', function(oldpicture) {
|
||||||
|
if(!oldpicture) {
|
||||||
uploadUserPicture(req.user.uid, path.extname(req.files.userPhoto.name), req.files.userPhoto.path, res);
|
uploadUserPicture(req.user.uid, path.extname(req.files.userPhoto.name), req.files.userPhoto.path, res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var absolutePath = path.join(global.configuration['ROOT_DIRECTORY'], global.nconf.get('upload_path'), path.basename(oldpicture));
|
||||||
|
|
||||||
|
fs.unlink(absolutePath, function(err) {
|
||||||
|
if(err) {
|
||||||
|
console.error('[%d] %s', Date.now(), + err);
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadUserPicture(req.user.uid, path.extname(req.files.userPhoto.name), req.files.userPhoto.path, res);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function uploadUserPicture(uid, extension, tempPath, res) {
|
function uploadUserPicture(uid, extension, tempPath, res) {
|
||||||
|
|||||||
Reference in New Issue
Block a user