从 MySQL 服务器中选择 jpg 图像后,当我尝试在单独的分区中回显它时,当我使用它时,它会显示为一堆 ascii 字符:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="image/jpeg; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<div id = "myDiv">
<h2>Div</h2>
<?php
require_once('appvars.php');
require_once('connectvars.php');
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$id = 1;
$query = "SELECT image FROM images WHERE id=?";
$stmt = $dbc->prepare($query);
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($image);
$stmt->fetch();
echo $image;
?>
</div>
</body>
</html>
在此先感谢您的帮助!