image not showing after getting from database in html form

in my page it is not showing images/.. in for images it is showing blank boxes
**i dont know where i am going wrong .. **

   <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>

**even i dont find any error… please make my correct and telll me why it is not showing any image **

 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);


 }


 ?>

i am stucked here please help me to get out from here


Source: html5

Leave a Reply