The HTML:
<form action="formhandler.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" name="submit" value="Submit" />
</form>
and doing a print_r($_FILES)
in formhandler.php after choosing a file and clicking submit yields:
[file] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
And error code 4, according to the manual stands for "UPLOAD_ERR_NO_FILE - No file was uploaded" but I can't figure out why it wasn't uploaded.
In this case, the problem was: I had multiple input elements with the attribute name="image"
. When I changed to individual names the error disappeared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With