1
I get an image in image:data format and need to save it as an image on the server, I tried:
var imageData = req.body.imagem.replace(/^data:image\/png;base64,/, "");
fs.writeFile(url, imageData, 'base64', function(err) {
if(err) res.send(err);
new UsuarioModel().updateFoto(req.body.id, url).then(function (rows) {
res.json(rows);
}, function (err) {
res.send(err);
})
});
This does not cause any error, generates the file with the correct name, however the images are blank, I have checked if the directories had permission and if the image:date was correct and everything is right. Someone would know how to solve this problem ?
express does not manage to receive files well. You need a plugin, multer is one of the most used as I know: https://github.com/expressjs/multer
– Sergio