duandushang5148 2013-02-01 12:24
浏览 201

如何在数据库中回显存储为blob的图像?

I was just wondering what the PHP code is to echo an image I've stored in a particular table of my database.

  • 写回答

3条回答 默认 最新

  • dongzhanlian6289 2013-02-01 12:30
    关注

    Well, here is the html you want for the image:

    <img src="image_render.php?image_id=4" /> <!-- or any unique identifier for that image -->
    

    in image_render.php you will want to do the following:

    // get the image information base on the unique identifier passed in the URL
     header("Content-Type: image/png"); // tell the browser that this is an image
     echo $imageBlog; // this is what you took from the database
    

    Make sure you don't add extra output in this file, or things will go bad.

    That's about it.

    Note

    In most situations it is better/faster to simply store the image location on the server instead of the whole image, so you probably need to document yourself a bit more before making this decision.

    Here is a discussion about the advantages and disadvantages of storing images in the database, and another one here.

    Good luck!

    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录