php – 我想显示图像而不是下载它(图像在数据库blob中)
发布时间:2020-12-13 17:04:57 所属栏目:PHP教程 来源:网络整理
导读:我想要显示图像而不是下载它. 我的数据库表中有图像,列为BLOB. 此代码段会下载图片,但我想显示它: $query = "SELECT * FROM upload";$result = mysql_query($query);$row = mysql_fetch_array($result);$content = $row['content'];$size = $row['size'];$t
我想要显示图像而不是下载它.
我的数据库表中有图像,列为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; 解决方法
如果你想使用它更动态地制作原始代码的脚本并像这样调用它:
<img src="image.php?imageid=$myImageID" /> 你的脚本是: $myImageID = $_GET["myImageID"]; $query = "SELECT * FROM upload where id='"+$myImageID+"'"; $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"); //header("Content-Disposition: attachment; filename=$name");---> this headers make system to download,but i dont want to download,i want to show image,what should i do,echo $content; ?>" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |