Forums

Require file upload

srkristen930 29 May, 2014
Hello, I would like to force my form to require 3 file upload inputs that I have. I use server validation to require the other fields, and they work fine. However, when I insert the field name of one of my file upload inputs, I always get an error that the field is empty - no matter whether I upload the file or not.
The file is uploaded to the server. BUt the form will not go through. If I remove the field from the server validation, then I can upload the file and receive it as an email.. but I can't force that field to be required.
What is the best way to require an upload field???
GreyHead 30 May, 2014
Hi srkristen930,

Because of the way that file uploads work the field name is empty until after the Upload Files action. You can run another check after that; or, probably better, you can create a Custom Serverside validation to check the PHP $_FILES array where the information about uploaded files is stored to start with.

Note that if you re-load the form then the existing File inputs won't be re-filled (because they need a local path on the users computer). And that you may get re-uploads of any files that were successfully uploaded unless you add code to disable these.

All in all it gets messy - client-side validation before the form is submitted to check that the inputs all have values in them is a good first step.

Bob
This topic is locked and no more replies can be posted.