How to decode base64 to image file in Node.js? How to decode base64 to image file in Node.js? express express

How to decode base64 to image file in Node.js?


I believe you need to use encodeUriComponent(base64) before sending to server.

try sending a JSON object, and parsing the image on the client side.

For example:

var mimeType = image.split(';')[0];var base64 = encodeUriComponent(image.split(',')[1]);var imageData = {  "mimeType" : mimeType,  "src" : base64}...xmlhttp.setRequestHeader("Content-type","application/json");xmlhttp.send(imageData);