当前位置: 动力学知识库 > 问答 > 编程问答 >

php - How we get image type from a base64_string

问题描述:

I got a base64 encoding string. Now i need to get string is a image type or not.

How it possible when image is in base64 string. I am very confused..

网友答案:

You can do this using

$imgData = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAA.';
$Imgpos  = strpos($imgData, ';');
$type = explode(':', substr($imgData, 0, $Imgpos))[1];
分享给朋友:
您可能感兴趣的文章:
随机阅读: