【发布时间】:2014-09-06 20:30:26
【问题描述】:
我已使用文本框将图像存储到 SQL 数据库并将其存储在数据库中,我如何从数据库中检索图像。我使用以下代码显示但它不起作用
// Grab the data from our people table
$sql = "select * from upload";
$result = mysql_query($sql) or die("Could not access DB: " . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
echo "<div class=\"picture\">";
echo "<p>";
// Note that we are building our src string using the filename from the database
echo "<img src=$row['data']/>";
echo $row['title'] . " " . $row['title'] . "<br />";
echo "</p>";
echo "</div>";
}
【问题讨论】:
-
你是如何存储图像的? base64 编码的原始图像字符串,或者?
-
您正试图将图像直接写入数据库。这不是它的工作原理。您将图像保存在数据库知道如何找到的位置...
标签: php sql database image forms