Show a BLOB image PHP MySQL along with other data

后端 未结 3 1441
终归单人心
终归单人心 2020-12-10 09:41

I have some data stored in a MySQL database .. i would like to show the stored image data along with other data in a .php page..

相关标签:
3条回答
  • 2020-12-10 10:04

    Read this: displaying an image stored in a mysql blob

    0 讨论(0)
  • 2020-12-10 10:04

    It depends how you stored you data, but sometimes you have to convert the data to base64. Try this

    echo '<img src="data:image/png;base64,' . base64_encode($blob_data) . '"/>
    
    0 讨论(0)
  • 2020-12-10 10:06

    If you set the header to image/jpeg that treats your entire page as an image file.. You want the data to be insert into the image holder only.

    Try something like this

    <img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />
    

    Where you will next echo the blob data into the image src

     <img alt="Embedded Image" src="data:image/png;base64,<?php echo $image->blob_data; ?> "/>
    
    0 讨论(0)
提交回复
热议问题