I have to code to insert data with image. when I insert information, the info will be saved into table except image and image name will be empty I do not know what the problem is?
The type of image is longblob and image name is varchar
addEmployee.php
<?php
session_start();
require 'common.php';
$connection = new mysqli($localhost , $dusername , $dpassword,$database);
if ($connection->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//echo "Connected successfully";
echo "<pre>";
//$EmpID = $_POST['EmpID'];
$SSN = $_POST['SSN'];
$Fname = $_POST['Fname'];
$Lname = $_POST['Lname'];
$PhoneNumber = $_POST['PhoneNumber'];
$Salary = $_POST['Salary'];
$Email = $_POST['Email'];
$JobTitle = $_POST['JobTitle'];
$Password = $_POST['Password'];
$image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
$name = addslashes($_FILES['image']['imageName']);
$query = "INSERT INTO `employee`( `SSN`, `Fname`, `Lname`, `PhoneNumber`, `Salary`, `Password`, `JobTitle`,`Email` , `image` , `name`)";
$query.= "VALUES('$SSN','$Fname','$Lname','$PhoneNumber','$Salary','$Password','$JobTitle' ,'$Email' ,'$image' ,'$name')";
$result = mysqli_query($connection, $query);
if (!$result)
{
echo "1";
die("Query failed". mysqli_errno($connection));
}
else {
header( "location: admin.html" );
}
?>