无法使用PHP输出图像

时间:2016-06-07 01:44:28

标签: php html mysql

$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,我正在尝试输出相同的图像。但我在浏览器中得到的就是这样。

enter image description here

0 个答案:

没有答案