How can i display an image wich saved as base64 encoded string?
It's store in 'jpegPhoto' attribute in LDAP.
I can display it with <img> tag directly like below:
<img src="data:image/jpeg;base64,***BASE64 ENCODED STRING HERE***" />
But IE doesn't support this.
I try to use web.header(), but failed:
web.header("Content-Type","image/jpeg")
***BASE64 ENCODED STRING HERE***
--
Best regards.
Zhang Huangbin
- Open Source Mail Server Solution for RHEL, CentOS,
Debian, Ubuntu:
+ Homepage: http://code.google.com/p/iredmail/
+ Forum: http://www.iredmail.org/forum/
<?php
header('Content-Type: image/png');
echo base64_decode($base64_encoded_str);
?>
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import web
urls = (
"/", "index",
"/img", "img",
)
app = web.application(urls, globals())
class index:
def GET(self):
return "<img src='/img' />"
pass
class img:
def GET(self):
web.header('Content-Type', 'image/png')
return "***BASE64 ENCODED STRING HERE***"
pass
if __name__ == "__main__":
app.run()