I don't know why this is not working. Please help me guys to come from it
<form action="login.php" method="post" enctype="multipart/form-data">
<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
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
There are 3 columns in database like id , name , image as long blob type
<?php
if(isset($_POST['submit']))
{
$con=@mysqli_connect("localhost","root","","work");
$imagedata=mysqli_real_escape_string($con,file_get_contents($_FILES['image'] ['tmp_name']));
$imagename=mysqli_real_escape_string($con,$_FILES['image'] ['name']);
$imagetype=mysqli_real_escape_string($con,$_FILES['image'] ['type']);
if(substr($imagetype,0,5) =="image")
{
$con=@mysqli_connect("localhost","root","","work");
mysqli_query($con,"INSERT INTO pics VALUES('$imagename','$imagedata')" or die (mysqli_error($con)));
}
else
{
echo"only images are allowed";
}
}
?>
<img src="showimage.php" />
showimage.php
<?php
$con=@mysqli_connect("localhost","root","","work");
$query = mysqli_query($con,"select* from pics" or die (mysqli_error($con)));
$row=mysqli_fetch_assoc($query);
$imagedata= $row["image"];
header("content-type: image/jpeg");
echo $imagedata;
?>
Please help me guys. I don't know what wrong I am doing here.