Here I have a basic html form with an choose file input and submit button. In my linked PHP page, I am trying to display the information of the file inside of an array in the browser, but am getting an undefined index error Undefined index: file
on each of the two lines of code where my two variables are. Why am I getting this error?
My HTML
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="upload.php" method="POST" enctype="mulitpart/form-data">
<input type="file" name="file">
<button type="submit" name="submit">UPLOAD</button>
</form>
</body>
</html>
My PHP code
<?php
if (isset($_POST['submit'])) {
$file = $_FILES['file'];
print_r($file);
$fileName = $_FILES['file']['name'];
}
you spelt "multipart/form-data wrong"