Gonzalo Grupe
Gonzalo Grupe

Reputation: 35

Image is not shown on php when I call mysql blob

I'm trying to get an image loaded on a mysql database as a blob. When I try to load, it just appear a black screen with a square in the middle. Like the image I attach.

please your help

PHP (file who show the image)

<?php
header("Content-type: image/jpeg");
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
require_once('sql.php');
require_once('encriptor.php');

$usrId = $_SESSION['usr-id'];
$sec= new encryptor();

$usrId = $sec->decrypt($usrId);

$db = new sql();

$consulta="CALL sp_getUserProfileImage(".$usrId.")";
$img="";
foreach($db->retorna($consulta) as $a)
{
    $img=$a->picture;
}

echo $img;
?>

this is the line where I call the image:

<img src="masterlib/php/image_show.php" class="img-circle" alt="User Image">

Image error

please your help, thanks a lot!

Upvotes: 1

Views: 59

Answers (1)

Vijunav Vastivch
Vijunav Vastivch

Reputation: 4191

Image in website need to have a directory like c:\images\sample.jpeg

You can't do it by fetching a blob from DB and assign the blob to an image control

Moving forward:

Save your image first then get the image file from your directory.

Upvotes: 1

Related Questions