How to removeError Undefined index ?
<?php
if(isset($_POST["submit"]))
{
echo $_POST["fileToUpload"]["name"]."Here";
}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" id="fileToUpload" >
<input type="submit" name="submit">
</form>
1 Answer
4 years ago by Ekarma PHP 007
In case you still have same problem, in case of input with file type and to get its content, you must use the superglobal $_FILES array.
In your case, it'd be
echo $_FILES['fileToUpload']['name']; // returns your file name
// Try
echo '<pre>';
print_r($_FILES['fileToUpload]);
echo '</pre>';
This should display all your chosen file keys => values like name, tmp_name, size, error, ...
From here, you can work on it according to your use case.
Good luck :)
3 years ago by MaMo20