if(preg_match('/^[a-zA-Z0-9]+\.(gif|jpe?g)$/',$row['filename'],$matches) &&
is_readable($row['filepath'].$row['filename'])){
echo header('Content-Type: image/'.$matches[1]);
echo header('Content-Length: '.filesize($row['filepath'].$row['filename']));
echo file_get_contents($row['filepath'].$row['filename']);
} else {
echo 'cant serve image: '.$row['filename'];
}
當我嘗試放置header('Content-Type': image/jpeg)
例如,它只顯示一個空白頁和當前的網址。圖片不顯示使用讀取文件/ file_get_contents
我試圖顯示一個圖像來代替我的<img>
標籤。
filepath包含圖像目錄的物理路徑。