Reputation: 2152
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\nKApXTsS54kDn7DdXew/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 .
Upvotes: 1
Views: 195
Reputation: 2759
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.
Upvotes: 1
Reputation: 5337
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">
Upvotes: 2