在我的页面中,它没有显示图像/..在图像中,它显示空白框 我不知道我哪里错了..
<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);
}
?>
我被困在这里,请帮助我离开这里
最佳答案
关于php - 以 html 形式从数据库获取图像后不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31804376/