php - 我想显示图像而不是下载图像(数据库 blob 中的图像)

标签 php

我想显示一张图片而不是下载它。

我的数据库表中有图像,列为 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/

相关文章:

php - 为什么我的 <td> 中的字体大小不会增加

php - fatal error : Cannot use object of type DOMNodeList as array

php - 解密使用 wp_hash() 生成的散列字符串

php - 我如何在 drupal 7 页面模板中创建一个 php 条件语句

php - yii2 显示错误信息

php - 错误的解释器 : No such file or directory on . sh 脚本

php - 根据分辨率计算拇指数

php - 如何从网络向应用程序发送 FCM 通知

php - 使用 Paypal cancel_return

php - json解码合并后