//url
let base64 = imgSrc.replace(/^data:image\/\w+;base64,/, "")
//buffer
let dataBuffer = new Buffer(base64, "base64")
//
let path = "static/upload/image"+".jpg"
//
fs.writeFile(path,dataBuffer,(err) => {
if(err) {
console.log(err)
}else {
console.log("")
}
})
what I do:
1. First, drop the url Filter of the base64 image to the data:image. in front of it. String
2. Convert the pictures of Filter to binary
3. Save to background with fs
but the saved picture cannot be parsed (as shown in the picture), so how can I get the picture at the front end?
in this way, the image obtained by the front end cannot be displayed because it cannot be parsed. Is it because I saved it in the wrong way? what should I do?