I try to upload image in my database. I write these code, but it's not update may database.
<?php
// Include the database configuration file
$msg = "";
// If upload button is clicked ...
if (isset($_POST['upload'])) {
$filename = $_FILES["uploadfile"]["name"];
$tempname = $_FILES["uploadfile"]["tmp_name"];
$folder = "./image/" . $filename;
$db = mysqli_connect("localhost", "root", "", "madrasadb");
// Get all the submitted data from the form
$sql = "INSERT INTO `smash` (`stuimage`) VALUES ('$filename')";
// Execute query
mysqli_query($db, $sql);
// Now let's move the uploaded image into the folder: image
if (move_uploaded_file($tempname, $folder)) {
echo "<img src=" . $folder . " height=200 width=300 />";
} else {
echo "<h3> Failed to upload image!</h3>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Image Upload</title>
</head>
<body>
<div id="content">
<form method="POST" action="" enctype="multipart/form-data">
Select Image File to Upload:
<input type="file" name="file">
<input type="submit" name="submit" value="Upload">
</form>
</div>
</body>
</html>