PHP:如何将图像从 URL 转换为 Base64?

标签 php binary base64

我想将图片从其 url 转换为 base64。

最佳答案

您要创建数据 URL 吗?然后您需要一个 MIME 类型和一些其他附加信息(参见 Wikipedia)。如果不是这种情况,这将是图像的简单 base64 表示:

$b64image = base64_encode(file_get_contents('path/to/image.png'));

相关文档:base64_encode()-function , file_get_contents()-function .

关于PHP:如何将图像从 URL 转换为 Base64?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4343715/

相关文章:

.net - CSS 中的 Base64 编码图像

objective-c - iOS7 应用内购买回执服务器验证的 Base64 编码怪异

php - 如何根据图像到中心图像​​的距离显示图像?

php - hhvm nginx 不返回 upload_max_filesize/post_max_size 的值

php - 获取匹配对

python - 为什么我无法执行存储在环境变量中的 shellcode?

php - 如何在不安装 Apache 2 的情况下卸载 php7.2-fpm(在 LEMP 机器上)

c++ - 将二进制对象读/写为十六进制?

c# - Dictionary<Key, Value> 上 .NET 二进制序列化的奇怪行为

iphone - 图像数据的 Base64 解码问题-iphone