I am having hard time displaying an image pulled out of a database using header('content-type:image/png'), it's returning an empty image and when I check the inspect element the img src name display the name of the php script, can anyone help please?
Here is part of the viewimage.php script attached with the img src
$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;
?>
Use readfile
or file_get_contents
if $row['fimgupload1_1']
is path to your file
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.