<?php
if (isset($_POST ["submit"])){
  $check = getimagesize($_FILES["image"]["tmp_name"]);
  if($check !== false){
    $image = $_FILES['image']['tmp_name'];
    $imgContent = addslashes(file_get_contents($image));

    $dbhost = 'localhost';
    $dbUsername = 'root';
    $dbPassword = '';
    $dbName = 'test';


    $db = new mysqli ($dbhost, $dbUsername, $dbPassword, $dbName);

    if ($db->connect_error);
    die("Connection Failed : " . $db->connect_error);
  }
  $insert = db->query("INSERT into test (image) VALUES('$image')");
  if ($insert){
    echo "File uploaded successfully.";
  }
  else{
    echo "File uploaded failed"
  }
  else {
    echo "Please select an image file to upload"
  }
  }
?>
