php 远程图片转base64

作者:

业务中涉及到物理删除图片,需要将原始图片以base64的方式存储下来

$imageInfo = getimagesize($picUrl);
$content = file_get_contents($picUrl);
$base64Data = 'data:' . $imageInfo['mime'] . ';base64,' . base64_encode($content);

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注