I just want some help from you guys. I want to upload an image file to database using and MYSQL. I'm having trouble on how to do it. I need your help. my code is example of how i want to upload the image. but I cant understand on how to do its. i have this 2 warnings when i try to execute the code
Warning: Undefined array key "image" in C:\xampp\htdocs\home-form\admin\create.php on line 52
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\home-form\admin\create.php on line 52
<?php
require_once "config.php";
$image = "";
$image_err = "";
if($_SERVER["REQUEST_METHOD"] == "POST") {
$input_image = trim($_FILES["image"]['name']);
if(empty($input_image)) {
$image_err = "Please enter skill.";
} else {
$image = $input_image;
}
if(empty($image_err)) {
$sql = "INSERT INTO employees (image) VALUES (?)";
if($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "b", $param_image);
$param_image = $image;
if(mysqli_stmt_execute($stmt)) {
header("location: dashboard.php");
exit();
} else {
echo "Oops! Something went wrong. Please try again later.";
}
}
mysqli_stmt_close($stmt);
}
mysqli_close($conn);
}
?>
enctypefor file uploads on your form?