How to save a PNG image server-side, from a base64 data URI
You need to extract the base64 image data from that string, decode it and then you can save it to disk, you don’t need GD since it already is a png. $data=”data:image/png;base64,AAAFBfj42Pj4″; list($type, $data) = explode(‘;’, $data); list(, $data) = explode(‘,’, $data); $data = base64_decode($data); file_put_contents(‘/tmp/image.png’, $data); And as a one-liner: $data = base64_decode(preg_replace(‘#^data:image/\w+;base64,#i’, ”, … Read more