I'm having trouble displaying a Base64 image inline.
Can someone point me in the right direction?
<!DOCTYPE html>
<html>
<head>
<title>Display Image</title>
</head>
<body>
<img style='display:block; width:100px;height:100px;' id='base64image'
src='data:image/jpeg;base64, LzlqLzRBQ...<!-- base64 data -->' />
</body>
</html>
You need to specify correct Content-type, Content-encoding and charset like
according to the syntax of the data URI scheme:
Also refer http://danielmclaren.com/node/90
My suspect is of course actual base64 data, otherwise it looks good to me. See this fiddle where similar scheme is working. You may try specifying char set.
You can try this base64 decoder to see if your base64 data is correct or not.
The + character occurring in a data URI should be encoded as %2B. This is like encoding any other string in a URI. For example, argument separators (? and &) must be encoded when a URI with an argument is sent as part of another URI.
you can put your data directly in a url statment like
and to get the image data u can use the php function
so you can copy paste the value of imageData and paste it directly to your url and assign it to the src attribute of your image
Try this one too:
Not recommended for production as it is only compatible with modern browsers.
This will show image of base 64 data: