Hello friends. I am trying to upload the photos in database, but it just saves the i.d of the pic which is primery key but not saving any picture and not returns any data. following is my code
Code:
<!DOCTYPE html>
<html>
<head>
<title>Image Upload</title>
</head>
<body>
<form action="imgupload.php" method="post" inctype="multipart/form-data">
<table border="1" width="50%" align="center">
<tr align="center"><td>
<input type="file" name="img1" required="required">
</td></tr>
<tr align="center"><td>
<input type="submit" name="submit" value="Upload">
</td></tr>
</table>
</form>
</body>
</html>
<?php
if (isset($_POST['submit'])) {
$imgname = $_FILES['img1'] ['name']; //line no 25
$tempimgname = $_FILES['img1']['tmp_name']; //line no 27
$con = mysqli_connect('localhost','root','','test1') or die(mysqli_error());
move_uploaded_file($tempimgname, "images/$imgname");
$sql="INSERT INTO`images`(`image`) VALUES ('$imgname')";
$run = mysqli_query($con,$sql);
echo "Uploaded Successfully";
}
?>
The error is showing is following.
Notice: Undefined index: img1 in C:\xampp\htdocs\PhpFolder\imgupload.php on line 25
Notice: Undefined index: img1 in C:\xampp\htdocs\PhpFolder\imgupload.php on line 27
Uploaded Successfully