MySQL Blob 未正确显示
您好,我之前问过一个类似的问题,关于从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法在网页内显示图像(您可以,但这是一个不同的故事,可能不是你想要的)。您需要将从数据库检索图像的代码放入一个单独的文件中,并使用以下命令将该文件包含在您的网页中
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