我想显示一张图片而不是下载它。
我的数据库表中有图像,列为 BLOB。
此代码段下载图像,但我想改为显示它:
$query = "SELECT * FROM upload";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$content = $row['content'];
$size = $row['size'];
$type = $row['type'];
header("Content-length: $size");
header("Content-type: $type");
// The following headers make the image download, but I don't want it to
// download, I want to show the image. What should I do?
// header("Content-Disposition: attachment; filename=$name");
echo $content;
最佳答案
attachment
的相反内容配置是inline
。试试这个:
header("Content-Disposition: inline; filename=$name");
关于php - 我想显示图像而不是下载图像(数据库 blob 中的图像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4089453/