I have a PHP form with an optional file input. If no file is chosen, and I do print_r($_FILES)
after submission, I get this:
Array ( [the_file] => Array (
[name] => [type] => [tmp_name] => [error] => 4 [size] => 0 )
)
On forms with no file input, the $_FILES array is just empty, which is what I would prefer to happen if the optional file attachment input isn't used. After all, the "errors" here are really not errors - the user didn't intend to submit a file.
Is there a way to prevent a blank file input from being submitted, apart from reworking the form to use AJAX?