I've tried to retrieve image from my Mysql Database in my ionic project, but only succeed when I call it from a column which contains a url to the image. If I call from a blob column which have an uploaded picture, it shows nothing.
Here my PHP code to create JSON from mysql data
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE");
header("Access-Control-Allow-Headers: Authorization");
$db_name = 'mydb';
$hostname = 'myhost';
$username = 'myuser';
$password = 'mypswd';
$email = $_GET['email'];
$dbh = new PDO("mysql:host=$hostname;dbname=$db_name", $username, $password);
$sql = 'SELECT * FROM users where email != "' .$email. '"';
$stmt = $dbh->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll( PDO::FETCH_ASSOC );
$json = json_encode( $result );
echo $json;
?>
Here my code to call a column contained a URL to the picture
<ion-item class="item-avatar item-icon-right" ng-repeat="user in users" type="item-text-wrap" href="#/tab/users/{{auth.profile.name}}/{{user.id}}">
<img ng-src={{user.avatar}}>
.....
<ion-item>
Column avatar is contained a URL to an image
But when I try to call a blob column like :
<img ng-src={{user.photo}}> //photo contains a blob image
It just shows nothing.