Please Help me out., I don't know why this give's Undefined index when i run the file it gives undefined index and when i hit the submit button its successfully uploaded file. and notification removed.
<html>
<body>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file"> <br><br>
<input type="submit" name="submit" value="submit"> </form>
</body>
</html>
$name = $_FILES ['file'] ['name'];
$size = $_FILES ['file'] ['size'];
$type = $_FILES ['file'] ['type'];
$max_size = 2097152 ;
$extension = strtolower(substr($name, strpos($name, '.')+1));
$tmp_name = $_FILES ['file'] ['tmp_name'] ;
$location = 'uploads/' ;
if (isset($name)) {
if (!empty($name)) {
if (($extension=='jpg'||$extension=='jpeg')&&$type=='image/jpeg'&&$size<=$max_size) {
if (move_uploaded_file($tmp_name, $location . $name)) {
echo "Uploaded!";
}
} else {
echo "file must be jpg/jpeg and must be 2mb or less.";
}
} else {
echo "Please Upload a File.";
}
}
Notice: Undefined index: file in C:\xampp\htdocs\Applications\File_Upload\upload.php on line 16
Notice: Undefined index: file in C:\xampp\htdocs\Applications\File_Upload\upload.php on line 17
Notice: Undefined index: file in C:\xampp\htdocs\Applications\File_Upload\upload.php on line 18
Notice: Undefined index: file in C:\xampp\htdocs\Applications\File_Upload\upload.php on line 21