The file componet is a powerful feature that allows users to upload multiple files directly to your SharePoint site, however it can sometimes be useful to restict the number of files a user is allowed to upload in a single submisisons. In this article we will outline two options to achive this.
Using multiple file component set to only allow a sinlge upload.
Using a file component allowing multiple uploads but with a custom validation rule to prevent submission if too many files are detected.
Option 1 - Multiple file components
The simplist way to restrict the number of file components would be to simply disable the "Multiple Values" option on your file component and drag and drop multiple file compoents into your form.
Drag and drop a file component into your form
Under the Data tab disable the "Multiple Values" option and save
Repeat this until the number for file components matches your maximum number of permissable files
Option 2 - Validation Rules
Having a single file component configure to allow multiple uploads can improve the look and feel of your form. For this reason, you may want to use a sinlge file component instead of the method outlined in option 1 above. In this secario you can use a custom validation rule to prevent submission if too many files are detected.
Drag and drop a file component into your form
Under the validation tab expand the "custom validation" section
Insert the following custom validation to restrict the number of files to 3
valid = instance.getValue().length < 3