Level 39
You forgot the submit in the form
<input type="submit" value="Upload Image" name="image">
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
When i'm uploading image in my form it gives me Undefined Array Key "image" i'm giving it the EncType and right name but i don't know where is the problem
MySQL insert code
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (isset($_POST['send'])) {
$First_Name = $_POST['First_Name'];
$Last_Name = $_POST['Last_Name'];
$Email = $_POST['Email'];
$Phone = $_POST['Phone'];
$Password = sha1($_POST['Password']);
$country = $_POST['country'];
$image = $_POST['image'];
if (isset($_POST['image'])) {
$imageName = $_FILES['image']['name'];
$imageType = $_FILES['image']['type'];
$imageTmp = $_FILES['image']['tmp_name'];
move_uploaded_file($imageTmp, "images/", $image);
}
$sql = "INSERT INTO users(first_name,last_name,email,phone,password,country,image) VALUES ('$First_Name','$Last_Name','$Email','$Phone','$Password','$country','$image')";
}
}
HTML Code
<form method="POST" action="index.php" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleInputPassword2">image</label>
<input type="file" class="form-control" id="exampleInputPassword2" name="image">
</div>
</form>
$_POST['image'] doesn't exist only $_FILES['image']
Please or to participate in this conversation.