3
我通过下面的代码获得了插入数据库的图像路径,但是我无法在html页面中显示它...图像的路径是"images/"
我如何显示实际图像?我努力尝试,但最让我工作的是显示文件名而不是图像。如何从存储在数据库中的路径显示图像?
<?php
$mysqli = new mysqli("localhost", "root", "", "simple_login");
// TODO - Check that connection was successful.
$photo= "images/" . $_FILES["file"]["name"];
$stmt = $mysqli->prepare("INSERT INTO photo (photo) VALUES (?)");
// TODO check that $stmt creation succeeded
// "s" means the database expects a string
$stmt->bind_param("s", $photo);
$stmt->execute();
$stmt->close();
$mysqli->close(
?>
这里是我试图显示图像......这只能说明与路径的文件名.....
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("simple_login", $con);
$result = mysql_query("SELECT * FROM photo");
while($row = mysql_fetch_array($result))
{
echo $row['photo'];
echo "<br />";
}
mysql_close($con);
?>
尝试使用的文件名与
标签 –
ioums
为什么在顶部使用'mysqli_',然后在底部使用'mysql_'? – Kermit
此外,顶部使用PDO,但底部使用不推荐使用的方法。 –