PHP:如何将图像从URL转换为Base64? [英] PHP: How to convert an image from URL to Base64?
本文介绍了PHP:如何将图像从URL转换为Base64?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将图像从其URL转换为base64.
I want to convert image from its url to base64.
推荐答案
是否要创建数据URL?然后,您需要MIME类型和其他一些信息(请参见 Wikipedia ).如果不是这种情况,则将是该图像的简单base64表示形式:
Do you want to create a data url? You need a MIME-Type and some other additional information then (see Wikipedia). If this is not the case, this would be a simple base64 representation of the image:
$b64image = base64_encode(file_get_contents('path/to/image.png'));
相关文档: base64_encode()
-功能,
Relevant docs: base64_encode()
-function, file_get_contents()
-function.
这篇关于PHP:如何将图像从URL转换为Base64?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文