Reputation: 1153
I am trying to do something that seems very simple. I want to upload a file into a directory on my server using PHP.
This is the form I am using:
<form action="getFile.php" method="post"><br>
Filename: <input type="file" name="uploadFile" id="uploadFile">
<input type="submit" value="Upload File">
</form>
Then, after I select a file and submit it, I am doing this in getFile.php:
<?php
var_dump($_FILES);
var_dump($_POST);
?>
And as an output I am getting this:
array(0) { } array(1) { ["uploadFile"]=> string(11) "Divider.png" }
So the $_FILES array is always empty, but the $_POST is bringing in my filename correctly. I have looked around and saw that write permissions may be an issue. I confirmed that executables were set to write:
And still no luck. What I am doing doesn't seem overly complicated, but I can't get the $_FILES array to give me anything. It does just get automatically filled from the form, right?
Thanks for your help.
Upvotes: 0
Views: 188
Reputation:
<form action="getFile.php" method="post" enctype="multipart/form-data"><br>
Filename: <input type="file" name="uploadFile" id="uploadFile">
<input type="submit" value="Upload File">
</form>
You need to add enctype="multipart/form-data"
Upvotes: 4