您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php image怎么转base64

2024/3/10 7:15:48发布23次查看
php image转base64的方法:1、获取一个图片地址;2、通过“chunk_split(base64_encode($gambar));”方法将图片转换为base64字符串格式即可。
本文操作环境:windows7系统、php7.1版、dell g3电脑
php image怎么转base64?
php 图片转 base64
以下代码使用 php 将图片转换为 base64 字符串格式:
实例
<?php//$file:图片地址//filetype: jpeg,png,gif$file = "encode.jpg";if($fp = fopen($file,"rb", 0)){ $gambar = fread($fp,filesize($file)); fclose($fp); $base64 = chunk_split(base64_encode($gambar)); // 输出 $encode = '<img src="data:image/jpg/png/gif;base64,' . $base64 .'" >'; echo $encode;} ?>
推荐学习:《php视频教程》
以上就是php image怎么转base64的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product