Here is the php script to fetch blob from MySQL database:
<?php
header('Access-Control-Allow-Origin: *');
$link = mysqli_connect("host","username","passwd", "database");
mysqli_set_charset($link, "utf8");
if(mysqli_connect_error()) {
die("There was an error");
}
$query = "SELECT pic FROM news WHERE id=1";
$rows = array();
if($result = mysqli_query($link, $query)) {
while($r = mysqli_fetch_assoc($result)) {
$rows[] = $r;
}
echo '<img src="data:image/jpeg;base64,'.base64_encode( $rows[0]['pic'] ).'"/>';
}
?>
No comments:
Post a Comment