How to upload a file chosen by user and insert it into a database

2020-02-15 php mysql file-upload

I have been trying to insert an image to the database but am failing. I am geting an error that Undefined index : image, all other information i can insert but image, is failing to insert below is the code please help.

$user = 'root';
$password = ''; //To be completed if you have set a password to root
$database = 'students'; //To be completed to connect to a database. The database must exist.
$port = NULL; //Default must be NULL to use default port
$mysqli = new mysqli('', $user, $password, $database, $port);

if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);

    $image = file_get_contents($_FILES["image"]["tmp_name"]);
    $query = "INSERT INTO `image` (`image`) VALUES('$image')";
        echo "succesfull";

        echo "undone";

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>image upload</title>
   <form method="POST" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit" value="submit">