Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function uploadImage(req, res) {
var eid = req.body.eid;
var image = req.body.eImage;
eid = eid.replace(/['"]+/g, '');
var imageName = eid;
console.log(imageName);
var imageBuffer = new Buffer(image, 'base64');
var options = {
filename: __dirname + '/../../public/uploads/' + imageName
};
base64.decode(imageBuffer, options, function (err, success) {
if(err) {
res.sendStatus(500).send(err);
}
else {
console.log(success);
var url = '/Web/public/uploads/' + imageName + '.jpg';
EventModel
.updateInitialPicture(eid, url)
.then(function (event) {
res.json(url);
}, function (error) {
res.sendStatus(500).send(error);
});
}
});
}