This code displays bunches of symbols rather than display the uploaded image
session_start();
include 'connection.php';
$id=$_SESSION["id"];
if (!isset($_SESSION['id'])) {
header("location:login.php");
}
?>
<?php
//DB Details
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPass = 'password';
$dbName = 'images';
//Create connection and select DB
$db = new mysqli ($dbHost, $dbUsername, $dbPass, $dbName);
Check DB connection
if ($db->connect_error) {
die ("Connection Failed: " . $db->connect_error);
}
//Get image data from database
$result = $db->query("SELECT image From images Where user_id=$id");
if ($result->num_rows > 0){
$imgData = $result->fetch_assoc();
Here am Rendering the Image
header("Content-type: image/jpeg");
echo $imgData['image'];
}else{
echo "Image not found...";
}
?>
When i try view the uploaded images it displays some bunch of symbols