I have an html form, which contains several form fields and a filename field (type=file), in a single php script.
Validation of form fields and the $FILES array are done in php.
The php script works fine if there are no form field validation errors.
However, if there are form field errors (empty form field, invalid field format, ...), the php script fails on subsequent submissions because the uploaded file is gone and the $FILES array is empty.
When the form is submitted, the file is uploaded before anything in php is done. If a validation error occurs, the form is redisplayed with the appropriate error messages.
However, the file is NOT uploaded again even though the file name is displayed in the form field.
I do not want to preform form validation in Javascript or JQuery.
Is there a better approach?