I have images stored in BLOB format in my database. My PHP code can access this BLOB data and return it to client side HTML page in JSON format.
How do I display this data on my HTML page?
I have tried using base64_encode but it works only for Firefox. THIS CODE IS NOT WORKING FOR CHROME, IE, OPERA.
Here is my PHP code:
$json2[] = array("Picture"=>base64_encode($row2[33]));
header("Content-Type: application/json; charset=UTF-8");
header("Content-type:image/jpeg");
echo json_encode($json2);
And this is my JQuery code:
success: function(data){
var str = JSON.stringify(data);
var obj = JSON.parse(str);
$('#pic0').html('<img height="40" width="40" src="data:image/jpeg;base64,' + obj[0].Picture + '" />');
}
success function is a part of AJAX call. My primary aim is to display this image in Mobile devices since this is a part of WebService Call. From what i have read, it seems base64_encode has some limitations in working for every browser.
How can I display the images on HTML page?
I have checked other posts in SO but unable to find anything fruitful.