$servername = "localhost";
$username = "root";
$password = "";
$conn = mysqli_connect($servername, $username, $password, "db_test");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}else{
$query = "SELECT * FROM `tab_gallery`";
$result = mysqli_query($conn,$query);
while($row = mysqli_fetch_assoc($result)) {
header("content-type: image/jpeg");
$image = $row['f_photo'];
?>
<img src="data:image/jpeg;base64,<?php echo base64_encode($image); ?>" />
<?php }
}
mysqli_close($conn);
?>
我上传了一个jpeg,我正在尝试输出相同的图像。但我在浏览器中得到的就是这样。