How to decode a base64 string (gif) into image in PHP / HTML

后端 未结 5 863
别那么骄傲
别那么骄傲 2020-12-06 04:51

I have a base64 encoded string that I would like to convert into an image in PHP / HTML.

Here is what I have:

$data = \"R0lGODdhAAGAAKIAAP38+/3h3cj         


        
5条回答
  •  悲&欢浪女
    2020-12-06 05:25

    Stupid question: is the mime-type correct?? is your base64 code represent a gif file????

    this is an example using a image/png, without php, just html, and it works:

    Embedded Image
    

    Just try it.

    Now, the same base64 code using the php exemplified above but using the proper mime-type (image/png):

    ";
    
    ?>
    

    So, this is the code:

    echo "Embedded";
    

    Notice, since I am using double quotes for the echo tag, I have to tell php to ignore the ones inside the img tag. Other than that, you are good

    cheers

    PC

提交回复
热议问题