嗨,我的数据库中有一个图像表.这些存储为blob以及图像类型和图像等细节.名称.
我在显示图像时遇到问题,我得到的只是一个带有红叉的白色方框.
码:
<?PHP
include '../connection.PHP';
$ID = $_GET['id'];
$query = "SELECT * FROM `images` WHERE `image_id` = '$ID'";
$result=MysqL_query($query);
$row = MysqL_fetch_array($result);
$image = $row['image'];
$image_type= $row['image_type'];
header("Content-type: $image_type");
print $image;
exit;
?>
谢谢
解决方法:
那么这是一个简短的答案.
<?PHP
include '../connection.PHP';
$id = (int)$_GET['id'];
$query = "SELECT * FROM `images` WHERE `image_id` = '$id'";
$result=MysqL_query($query);
$row = MysqL_fetch_array($result);
$image = $row['image'];
$image_type= $row['image_type'];
$size = $row['image_size'];
//alternative
/* list($image, $image_type, $size) = array(
$row['image'],
$row['image_type'],
$row['image_size']
);
*/
$ext = explode('/', $image_type);
$name = $id . '.' . $ext[1];
header("Content-type: $image_type");
header("Content-length: $size");
header("Content-disposition: attachment; filename=$name");
print $image;
exit;
检查您的blobtype是最少的MEDIUMBLOB,它能够存储高达16M的数据
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。