把图片转为base64格式

base64编码:图片的base64编码指将一副图片数据编码成一串字符串,使用该字符串代替图像地址

  • $img_file = file_get_contents($url);

  • $img_content= base64_encode($img_file);

  • $type = 'jpeg';//得到图片类型jpg

  •  $new_file = "./cs/cs.{$type}";

  • file_put_contents($new_file, base64_decode($img_content)))

猜你喜欢

转载自blog.csdn.net/littlexiaoshuishui/article/details/82951583