开发者

images using json?

I am trying to load an image from the database which is base 64 array into the HTML . it has around 204 characters . I am also trying to load the name and other details .It returns the following JSON

07-18 18:33:52.732: ERROR/HTMLContacts(1098): Json: google json [{"contactId":"1","contactPhoto":"iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAAA3NCSVQFBgUzC42AAAAgAElEQVR4\nnK29f4wc93Un+OnvvBq976iarBKnpSnJbbklj3xDL5kldVJAeqVA9Nne0Ih9J0IRvEIiXHf31AQmUelEgUB0V3d2FhfXu450XTBqlf1Cq+J4QqwisQgMaRGYZpTMUCADkZDS6Reik6n\nKApXT开发者_运维技巧sS54kDn7DdXew/2Sre9eFdR3Jer

Good part of it is truncated . I assume that it has crossed JSON limit hence it truncated the other details . Is there any good way to send the array so that i can display image in HTML ? Thanks in advance .

NOTE : I need to send multiple images maybe 10 at a time .


To use the base-64 data in the SRC of an IMG tag, turn it into a data-url, like so (assuming the image is PNG, change the mimetype as appropriate) :

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAAAA3NCSVQFBgUzC42AAAAgAElEQVR4\nnK29f4wc93Un+OnvvBq976iarBKnpSnJbbklj3xDL5kldVJAeqVA9Nne0Ih9J0IRvEIiXHf31AQmUelEgUB0V3d2FhfXu450XTBqlf1Cq+J4QqwisQgMaRGYZpTMUCADkZDS6Reik6n\nKApXTsS54kDn7DdXew/2Sre9eFdR3Jer">


On browser side, you could refer to this post for base64 encoding. On server side, the ways variant depending on which language you are using on the server side.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜