I am trying to display an image from my database but it isn't showing on the website. How do i get the image to display through php?
我试图从我的数据库显示图像,但它没有在网站上显示。如何通过PHP显示图像?
Database set up
数据库设置
Php code
print " <td><img src='Img.php?id=" . $row["id"] . "' /></td>";
1 个解决方案
#1
1
1st guess, the img
column contains a link in which case it will be
第一个猜测,img列包含一个链接,在这种情况下它将是
echo " <td><img src='" . $row["img"] . "' /></td>";
echo“ ”;
2nd guess, the img
column is base64 encoded image in which case it will be
第二个猜测,img列是base64编码的图像,在这种情况下它将是
echo " <td><img src='data:image/gif;base64," . $row["img"] . "' /></td>";
echo“ ”;
I think, that is off the top of my head.(if image is gif, amend accordingly)
我想,这是我的头脑。(如果图像是gif,相应修改)
3rd guess, some wizardry going on? perhaps img.php is doing the base64 decode for you?
第三个猜测,有些巫术在继续吗?也许img.php正在为你做base64解码?
I would recommend storing the image on disk or S3 or something then storing the path in the DB.
我建议将图像存储在磁盘或S3上,然后将路径存储在数据库中。
#1
1
1st guess, the img
column contains a link in which case it will be
第一个猜测,img列包含一个链接,在这种情况下它将是
echo " <td><img src='" . $row["img"] . "' /></td>";
echo“ ”;
2nd guess, the img
column is base64 encoded image in which case it will be
第二个猜测,img列是base64编码的图像,在这种情况下它将是
echo " <td><img src='data:image/gif;base64," . $row["img"] . "' /></td>";
echo“ ”;
I think, that is off the top of my head.(if image is gif, amend accordingly)
我想,这是我的头脑。(如果图像是gif,相应修改)
3rd guess, some wizardry going on? perhaps img.php is doing the base64 decode for you?
第三个猜测,有些巫术在继续吗?也许img.php正在为你做base64解码?
I would recommend storing the image on disk or S3 or something then storing the path in the DB.
我建议将图像存储在磁盘或S3上,然后将路径存储在数据库中。