0

in php we can replace multiple string with array like this

$cleanbase64 = base64_decode(str_replace(array('-', '_',' ','\n'), array('+', '/','+',' '), $base64file));

but how to implement that to javascript , i tried like this

const cleanbase64 = base64file.replace(/\-/, "+").replace(/_/, "/").replace(/ /, "+").replace(/\n/, " ");
const buffer = Buffer.from(cleanbase64, 'base64');

but the base64 seems broken , and i can't convert into image

taqin
  • 29
  • 4

0 Answers0