This answer might be useful for processing the image.
This answer might be useful for validating the image.
Code:
$data = 'data:image/png;base64,iVBORw0KG.....';
list($type, $data) = explode(';base64,', $data, 2);
$data = str_replace(' ', '+', $data);
$data = base64_decode($data);
if (imagecreatefromstring($data) == false) { echo "invalid_image"; die(); }
file_put_contents('/storage/folder/image.png', $data);
You might also want to restrict file types.
You must keep in mind that you can't simply trust any of the data sent from the client (like 'data:image/png'), so you must rely on other means (some php functions).