HTML/PHP Get the content of a .txt file user-side with file_get_contents()
I am trying to print on the page the content of a
.txt file that the user would have uploaded beforehand.
This is the code I have so far:
<form action="page.php" method="POST"> <input type="file" name="userfile"/> <input type="submit" value="Load"/> </form>
On page.php :
<?php echo file_get_contents($_POST['userfile']); ?>
The error I get:
"Warning: file_get_contents(userfile.txt): failed to open stream: No such file or directory"
It does work when the
.txt file is in the same directory as the
But the files that will be printed won't be in this directory, on the server.
How can I do that?
Thanks for your answers!
Use enctype="multipart/form-data" in form