So I've been looking around and could only find a way to save the image to a server if the data you send is in base64. I am sending the data as regualar data so nothing I found worked.
Thanks
This is what I tried to use:
<?php
$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);
?>
I also tried this:
$data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $data));