I tried to link stored image(blob data) inside MySQL DB to PHP but only thing I achieved was whole page of characters. This is what I did:
$query = "SELECT image FROM uploads WHERE id = {$id}";
$image_array = mysql_query($query, $connection);
$row = mysql_fetch_array($image_array);
$image = $row['image'];
echo $image;
// echo base64_decode($content);
This displays raw data how it is stored. I would like to link it into HTML tag or atleast display it on page, where I display a lot another stuff to so header('Content-type: image/png'); is not solution for me.
Any advice?
To show the image correctly you just need to put one header with Content-type: image/png
before echo
header("Content-type: image/png");
echo (base64_decode($row['image']));
If you want to place instead in an image tag you just need to use this code
echo '<img src="data:image/png;base64,' . $row['image'] . '" />';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With