I get base64 string from my android appliation using which the php script saves it to the directory everything works fine for png. except i need the script to work for all image types At android side i have httpservlet extended class and using which i send a get request with a variable containing base64 string. So all we have is a base64 string nothing else at server side Can you help me with that?? This is my php code
<?php
$imgstr = $_REQUEST['string'];
// Decode the data
$data = base64_decode($imgstr);
$im = imagecreatefromstring($data);
if ($im !== false) {
header('Content-Type: image/png');
imagepng($im);
$success = file_put_contents("img/abc". uniqid().".png", $data);
imagedestroy($im);
if ($success) {
echo 'yes yes yes';
}
} else {
echo 'An error occurred.';
} ?>