MySQL Blob 未正确显示

发布于 2024-08-12 14:53:31 字数 318 浏览 4 评论 0原文

您好,我之前问过一个类似的问题,关于从 MySQL 数据库 Blob 检索图像。

我使用的代码为:

header("Content-type: image/jpeg"); // change it to the right extension 
print $image;   //where image is the blob file

此代码嵌套在网页内,所以我还应该修改标题吗?当我包含 header() 时,它会删除所有网页代码,我认为这是因为我正在更改浏览器渲染为 image/jpeg 的文件类型?如何显示网页内的图像?谢谢!

Hi I asked a similar question earlier about retrieving an image from a MySQL database Blob.

I am using code as:

header("Content-type: image/jpeg"); // change it to the right extension 
print $image;   //where image is the blob file

This code is nested inside of a webpage, so should I still modify the header? When I include the header() it removes all of the webpage code which I assume is because I am changing the file type the browser is rendering to image/jpeg? How can i show the image inside of a webpage? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自此以后,行同陌路 2024-08-19 14:53:31

您无法在网页内显示图像(您可以,但这是一个不同的故事,可能不是你想要的)。您需要将从数据库检索图像的代码放入一个单独的文件中,并使用以下命令将该文件包含在您的网页中

<img src="filename.php">

You can't show an image inside a webpage (well you can, but that's a different story and probably not what you want). You need to put the code that retrieves the image from a database into a separate file, and include this file in your web page using

<img src="filename.php">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文