gpt4 book ai didi

php - 以 html 形式从数据库获取图像后不显示

转载 作者:行者123 更新时间:2023-11-29 22:09:39 24 4
gpt4 key购买 nike

在我的页面中,它没有显示图像/..在图像中,它显示空白框我不知道我哪里错了..

   <form action="login.php" method="post" enctype="multipart/form-data">
<input type="text"
<br><br><br>
select image:<input type="file" name="image" size="40" id="image">
<br><small> must be less than 512kb </small>

<br><br> <input type="submit" name="submit" value="submit">
</form>

即使我没有发现任何错误...请纠正我并告诉我为什么它没有显示任何图像

   <?php

if(isset($_POST['submit']))
{
if(getimagesize($_FILES['image'] ['tmp_name'])==FALSE)

{
echo "<script> please insert the image </script>";
exit();
}

else
{
$image=addslashes($_FILES['image'] ['tmp_name']);
$name=addslashes($_FILES['image'] ['name']);
$image= file_get_contents($image);
$image= base64_encode($image);
saveimage($name,$image);


}
}

displayimage();

function saveimage($name,$image)
{
$con=@mysqli_connect("localhost","root","","work");

$qry="insert into pics( name, image) values('$name','$image')";

$result= mysqli_query($con,$qry);

if($result)
{
echo"<br> image uploaded";
}

else
{
echo"<br> image not uploaded";
}

}

function displayimage()
{
$con=@mysqli_connect("localhost","root","","work");

$qry= "select* from pics";

$result= mysqli_query($con,$qry);

while($row = mysqli_fetch_array($result))
{
echo"<img height=\"250\" width=\"250\" src=\"data:image;base64,\" '.$row[2].' >";
}
mysqli_close($con);


}


?>

我被困在这里,请帮助我离开这里

最佳答案

也许这有帮助: How to display Base64 images in HTML?

您能否向我们提供生成的 html?

也许您必须提供文件类型,jpg/png:

关于php - 以 html 形式从数据库获取图像后不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31804376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com