开发者

In PHP how do I take a base64 encoded png and output that png as an image? [duplicate]

This question already has answers here: 开发者_运维问答 Closed 10 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜