image.php
<?php
include('config.php');
if(isset($_POST['upload'])){
$name=$_POST['name'];
$email=$_POST['email'];
$image_name=$_FILES['image']['name'];
$tmp_image=$_FILES['image']['tmp_image'];
$folder="upload_image/".$image_name;
move_upload_file($tmp_image,$folder);
$sql="insert into 'image' ('name','email','image_name') values('$name','$email','$folder')";
if(mysqli_query($conn,$sql))
{
echo "Data Inserted";
}
else
{
echo "connection error";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title> Image Upload</title>
</head>
<body>
<form action="" method="post"enctype="multipart/form-datas">
<label for="fname">Name:</label><br>
<input type="text" id="name" name="name" placeholder="Enter your Name"><br>
<br>
<label for="email">Email"</label><br>
<input type="text" id="email" name="email" placeholder="Enter your Email"><br><br>
<label for="image">Image:</label><br>
<input type="file" id="image" name="image"><br><br>
<input type="Submit" name="upload" value="Upload Image"
</form>
</body>
</html>
config.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "staff";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>