I tried to upload a file into a mySQL database using this code
<html>
<body>
<label for="exampleInputPassword1">Upload a photograph</label>
<input type="file" class="form-control" id="file" tname="file" required>
<button type="submit" class="btn btn-default">Submit</button>
</body>
</html>
<?php
if ($_FILES["file"]["error"] > 0) {
echo "Error: " . $_FILES["file"]["error"] . "<br>";
} else {
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
?>
But I get these notices
Notice: Undefined index: file in C:\xampp\htdocs\tachi\html\admin\addplace\insert_place.php on line 2
Notice: Undefined index: file in C:\xampp\htdocs\tachi\html\admin\addplace\insert_place.php on line 5
Upload:
Notice: Undefined index: file in C:\xampp\htdocs\tachi\html\admin\addplace\insert_place.php on line 6
Type:
Notice: Undefined index: file in C:\xampp\htdocs\tachi\html\admin\addplace\insert_place.php on line 7
Size: 0 kB
Notice: Undefined index: file in C:\xampp\htdocs\tachi\html\admin\addplace\insert_place.php on line 8
Stored in:
How to fix this problem. From where can I identify whether the photograph has been uploaded into the database and how?