如何将图像从 URL 转换为 Base64 编码?
最佳答案
我认为应该是:
$path = 'myfolder/myimage.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
关于php - 如何将图像转换为 Base64 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3967515/