In PHP how do I take a base64 encoded png and output that png as an image? [duplicate]
Possible Duplicate:
get image from base64 string
I tried
header('Content-Type: image/png');
echo base64_decode($data);`
But it doesn't work.
A png data url looks like this:
data:image/png;base64,[actual data]
You have to cut the beginning to be able to base64_decode
it.
Also, if you remove the header
call, you will be able to see any error message your code outputs.
PHP has this magical function named imagecreatefromstring() too... But there is no need to use it if you need to show image only.
Thank you everyone for trying to help. The problem was I was that I forgot to url encode the query parameter before I sent it to the PHP script.
精彩评论