dimanche 12 avril 2015

How to test if a base64 string is a valid image in PHP?


Vote count:

0




How to test if a base64 string is a valid image in PHP?


I tried the following code:



function convertAndSaveLogo($data, $id){
if(isset($data->base64_image) && $data->base64_image){
$imageData = base64_decode($data->base64_image);
if($imageData){
$source = imagecreatefromstring($imageData);
if($source){
imagepng($source, getcwd()."../dir/image/".$id.".png", 5);
imagedestroy($source);
}
}
}
}


But it is not working.



asked 22 secs ago







How to test if a base64 string is a valid image in PHP?

Aucun commentaire:

Enregistrer un commentaire