我很难显示使用标题('content-type:image / png')显示从数据库中取出的图像,它返回一个空图像,当我检查inspect元素时,img src名称显示名称php脚本,有人可以帮忙吗?
以下是img src附带的viewimage.php脚本的一部分
$data = "SELECT fimgupload1_1 FROM controlpanel1";
$result2 = mysqli_query($connection,$data);
while ($row = mysqli_fetch_array($result2))
{
$imgData = $row['fimgupload1_1'];
}
header('Content-Type: image/png');
echo $imgData;
?>
答案 0 :(得分:0)
如果readfile
是您文件的路径,请使用file_get_contents
或$row['fimgupload1_1']
$data = "SELECT fimgupload1_1 FROM controlpanel1";
$result2 = mysqli_query($connection,$data);
while ($row = mysqli_fetch_array($result2))
{
$imgData = $row['fimgupload1_1'];
}
header('Content-Type: image/png');
echo readfile($imgData);