Skip to main content

betaThis is a new capability. Help us improve it and give your feedback on Slack.

File Upload Field

File manager component that displays uploaded files from session state.

This component renders the list of files already in session state, allows the user to remove individual files, and enforces min/max file count constraints. On final form submission it calls persistFiles() to move files to permanent storage. It does not handle uploading — that is the responsibility of the page controller. See FileUploadPageController for the provided Defra implementation.

Preview

This component is progressively enhanced. File uploads work without JavaScript using standard form submission. With JavaScript enabled, users get real-time upload progress.

To see the full experience, view our demo form which includes most components.

No files uploaded

Uploaded files

0 files uploaded

With files uploaded

Uploaded files

annual-report.pdf
Uploaded
Remove annual-report.pdf
supporting-evidence.docx
Uploaded
Remove supporting-evidence.docx

JSON definition

{
"type": "FileUploadField",
"name": "fieldName",
"title": "Question title",
"hint": "",
"shortDescription": "",
"options": {},
"schema": {}
}

Properties

PropertyTypeRequiredDescription
hintstringNoHint text displayed below the field label to help the user answer the question.
shortDescriptionstringNoA short description of the field used in the check-your-answers summary.

Options

PropertyTypeRequiredDescription
acceptstringNoComma-separated list of accepted MIME types (e.g. 'image/png,application/pdf').
classesstringNoAdditional CSS classes applied to the component.
customValidationMessagesobjectNoA map of Joi error codes to custom error messages.
instructionTextstringNoAlternative text read by screen readers in place of the field title.
optionalTextbooleanNoWhen true, appends '(optional)' to the field label.
requiredbooleanNoWhether the field must be filled in. Defaults to true.

Schema constraints

PropertyTypeDescription
maxnumberMaximum value, character length, word count, or file count.
minnumberMinimum value, character length, word count, or file count.
lengthnumberExact character length required.