0
I saved an image in the BD in a field type BLOB but when displaying it does not display the image, instead it leaves the screen black with a white square in the middle follows the code:
<?php
$query = mysqli_query($link, "select * from imagem");
while($row = mysqli_fetch_array($query)){
header('Content-Type: image/jpeg');
echo '<img src="renderiza.php?id="' . $row["id"] . '"/>';
}
?>
filing cabinet php rendering.
<?php
$link = mysqli_connect("localhost", "root", "", "teste");
$uid = $_GET["id"];
$query = mysqli_query($link, "select * from imagem WHERE id = '$uid'");
$image = mysqli_fetch_array($query);
$foto = $image['foto'];
header('Content-Type: image/jpeg');
echo $image['foto'];
?>
You are trying to render the image directly, it will not work. You need to have another file that renders this image in Html.
– user13603
Now I saw that it was edited and better to see. Have you ever tried to render without being in the loop? Directly in html?
– user13603
There are extra quotes in your type code
echo '<img src="renderiza.php?id=' . $row["id"] . '"/>';
– novic
Take a look at this link Function blob2image($mime, $blob){ ob_start(); header("Content-type:$mime"); echo $blob; Return ob_get_contents(); } $mime = 'image/png'; foreach($result as $Row){ echo $Row['name']; echo '<img src="data:'. $mime. ';Base64,'. base64_encode(blob2image($mime, $Row['img'])). '"/>'; }
– mcamara
I already answered a similar question in another post. POST All right it was for APP Desktop, but it does not fail to apply to any type of application (Mainly WEB)
– hynzhw