How to display a imaget is stored in database

43 Views Asked by At

I'm not getting any image that i stored in my database . the path of image is stored in database . But whenI try to get image it show me a blank page.\

Notice: I want to show images as well as text . So please don't write header.`

<?php

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "db_dat";

$s='';
$conn = mysqli_connect($servername, $username, $password, $dbname);

$uploadDir = 'C:\wamp\www\images\passport images';

$sql = "SELECT * from upload2 ";
$result = $conn->query($sql);
    while($row = $result->fetch_assoc()) {
        echo '<img src=  "'.$uploadDir.'" ."'.$row['name'].'">' ;
}



 ?>

`

1

There are 1 best solutions below

0
On

try this

<?php

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "db_dat";

$s='';
$conn = mysqli_connect($servername, $username, $password, $dbname);

$uploadDir = 'http://localhost/images/passport images';

$sql = "SELECT * from upload2 ";
$result = $conn->query($sql);
    while($row = $result->fetch_assoc()) {
        echo '<img src=  "'.$uploadDir.'" /"'.$row['name'].'">' ;
}



 ?>