此代码显示一串符号,而不是显示上传的图像
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);
检查数据库连接
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();
这是渲染图像
header("Content-type: image/jpeg");
echo $imgData['image'];
}else{
echo "Image not found...";
}
?>
当我尝试查看上传的图像时,它会显示一些符号