簡體   English   中英

沒有圖片顯示標題(“內容類型:image / png”)

[英]No image displayed with Header('Content-type: image/png')

我很難顯示使用header('content-type:image / png')從數據庫中提取的圖像,它返回一個空圖像,當我檢查檢查元素時,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;
    ?>

如果$row['fimgupload1_1']是文件的路徑,請使用readfilefile_get_contents

$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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM