I am trying to store image in SQL database blob. I followed a tutorial but I keep getting this error.
<form action="upload.php" method="POST">
<input type="file" name="image">
<input type="submit" name="submit" value="upload">
</form>
<?php
if(isset($_POST['submit']))
{
$conn= mysqli_connect("localhost","root","");
mysqli_select_db($conn, "namastedb");
$imageName = mysqli_real_escape_string($conn, $_FILES["image"] ["name"]);
$imageData = mysqli_real_escape_string($conn, file_get_contents($_FILES["image"] ["tmp_name"]));
$imageType = mysqli_real_escape_string($conn, $_FILES["image"]["type"]);
if(substr($imageType, 0, 5) == "image")
{
mysql_query("insert into 'product_details' values('','1','$imageName','$imageData') ");
echo "Image Uploaded.";
}
else
echo "Only images are allowed!";
}
?>
Notice: Undefined index: image in C:\xampp\htdocs\Namaste\upload.php on line 16
Notice: Undefined index: image in C:\xampp\htdocs\Namaste\upload.php on line 17
Warning: file_get_contents(): Filename cannot be empty in C:\xampp\htdocs\Namaste\upload.php on line 17
Notice: Undefined index: image in C:\xampp\htdocs\Namaste\upload.php on line 18 Only images are allowed!