下面是我試過的簡單代碼。如何顯示存儲在mysql數據庫中的圖像
我不能夠顯示在數據庫中呈現的圖像
請幫我在這方面。
我用兩個文件
1)db.php中
這是連接mysql數據庫並獲得一個記錄。
影像將被保存在一個JP2格式。
2)test.php的
使用PHP顯示記錄。
**如果圖像保存在JP2格式再然後我如何可以轉換這些圖像,並顯示到網頁中。
如果IAM使用該代碼的一些垃圾(字節碼說吧)被伊恩顯示網頁**
這是我db.php中
<?php
function getResidentPhoto() {
$dbcnx = @mysql_connect('127.0.0.1', 'root', '[email protected]');
if (!$dbcnx) {
die('<p>Unable to connect to the ' . 'database server at this time.</p>'
);
}
if ([email protected]_select_db('finaldb')) {
die('<p>Unable to locate the ' . 'database at this time.</p>');
}
$selectrc = 'select BPFT_Photo from photo_templates limit 1';
$result = @mysql_query($selectrc, $dbcnx);
if (!$result) {
die('<p>Error performing query: ' . mysql_error() . '</p>');
} else {
}
$n = mysql_num_rows($result);
$row = mysql_fetch_assoc($result);
if ($n > 0) {
$Photo_Details = $row['BPFT_Photo'];
return $Photo_Details;
}
}
?>
和我的test.php的是
<?php
echo' <html>';
echo'<body>';
echo' <table>';
echo' <tr><td>';
$residentPhoto = getResidentPhoto();
$image_type_to_mime_type0 =image_type_to_mime_type($residentPhoto)
header('Content-type:$image_type_to_mime_type0');
echo' '.$residentPhoto;
echo'</td>';
echo'</tr>';
echo'</table>';
echo'</body>';
echo'</html>';
?>
什麼,如果有的話,是在發生? –
你有什麼錯誤?我們應該怎麼知道'$ row ['BPFT_Photo']'包含了什麼? – naththedeveloper
爲什麼不將圖像路徑存儲到數據庫中並將圖像上傳到服務器中。 – sabbir