我无法在网页中显示 jp2 图片。
这是从数据库获取图像并将其显示到网页的主文件。
数据库中的图像格式为JP2图像格式。
<?php
echo' <html>';
echo'<body>';
echo' <table>';
echo' <tr><td>';
$dbcnx = @mysql_connect('127.0.0.1', 'root', 'root@19211');
if (!$dbcnx) {
die('<p>Unable to connect to the ' . 'database server at this time.</p>'
);
}
if (!@mysql_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);
$Photo_Details = $row['BPFT_Photo'];
$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>';
?>
最佳答案
浏览器必须支持jp2图像,否则看不到..
以及您使用什么方法将其添加到网页中
(我认为你使用了 echo)。但是 echo 不会做任何事情,只会将一些字符写入网页
您必须从数据库获取图像并将其保存在服务器中的临时文件夹中并回显网络路径
示例:
$path="root/tmp/photo.jp2";
echo '<img src=$path>';
关于php - 从mysql数据库获取jp2图像并使用php在网页中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21953098/