<?php
$msg = "";
if (isset($_POST['upload'])){
$target = "images/".basename($_FILES['image']['name']);
$db = mysqli_connect("localhost", "root", "", "photos");
$image = $_FILES['image']['name'];
$text = $_POST['text'];
$sql = "INSERT INTO images (image, text) VALUES ('$image', '$text')";
mysqli_query($db, $sql);
// Now let's move the uploaded image into the folder: images
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)){
$msg = "image upload successfully";
}else{
$msg = "There was a problem uploading image";
}
}
?>
What I have tried:
Notice: Undefined index: image in C:\xampp\htdocs\projects\upload_image\index.php on line 7
Notice: Undefined index: image in C:\xampp\htdocs\projects\upload_image\index.php on line 12
Notice: Undefined index: image in C:\xampp\htdocs\projects\upload_image\index.php on line 20