base64转图片 图片转base64

    xiaoxiao2021-04-13  37

    <?php //图片转成base编码 $file="images/2.gif"; $type=getimagesize($file);//取得图片的大小,类型等 $file_content = base_encode(file_get_contents($file)); $img='data:image/'.$img_type.';base64,'.$file_content;//合成图片的base64编码 echo '<img src= '. $img .'>' ?> <?php //编码转成图片 $url = explode(',',$file_content); file_put_contents('./test.png',base64_decode($url[1]));//存储图片到对应的位置
    转载请注明原文地址: https://ju.6miu.com/read-668594.html

    最新回复(0)