Application · lesson 22 of 34 · Input And Data Entry

File upload

Underlying principle: An input pattern carries a question, an expected answer, and a consequence. Visible labels, suitable controls, tolerant entry, and specific recovery keep that agreement clear.

Provide a labelled file upload control that states requirements up front, uses a reliable file chooser, displays selected file details, validates type and size, shows progress and outcome, supports removal and retry, and preserves the surrounding task state.

Start with the decision

Does this fit your task?

The service needs a document, image, scan, spreadsheet, media file, or other original file.

Review the boundary: Compare the task with the alternatives in the decision section.

Review the decision →
Study the interaction

Follow the task before choosing the component

An input pattern carries a question, an expected answer, and a consequence. Visible labels, suitable controls, tolerant entry, and specific recovery keep that agreement clear.

01 / Recognize the need

What the person is doing

The product needs the original file for evidence, identity, compliance, media review, document processing, or support investigation.

02 / Design the response

What the interface must communicate

Provide a labelled file upload control that states requirements up front, uses a reliable file chooser, displays selected file details, validates type and size, shows progress and outcome, supports removal and retry, and preserves the surrounding task state.

Empty labelled state with requirements hint and choose-file action.

03 / Judge the outcome

What to look for

Why does the service need the original file rather than a typed value?

Activating the choose-file button opens the platform file picker and returns focus to the invoking control or selected file summary afterward.

Decision first

Choose this pattern when the problem matches

Use when

  • The service needs a document, image, scan, spreadsheet, media file, or other original file.
  • Users can reasonably access the file on their current device or have a supported alternate route.
  • The product can validate files, store or transmit them securely, and explain upload status.
  • Users need to review, remove, replace, retry, or confirm attachments before continuing.

Avoid when

  • A typed answer, reference number, checkbox, or declaration would satisfy the task.
  • The file is optional decoration rather than critical evidence or content.
  • The workflow actually needs a bulk import with row validation, mapping, and import results.

Problem it prevents

The product needs the original file for evidence, identity, compliance, media review, document processing, or support investigation.

Test the behavior

Try strong and weak versions of the interaction

Open the working example, try its controls, and compare the behavior against the decision guidance.

In the lab you can
  • switch between strong UI, weak UI, strong UX, and weak UX;
  • trigger required, empty, loading, error, and recovery states;
  • inspect keyboard and accessibility expectations beside the demo.
Launch File upload in the lab
Pattern anatomy

What a strong implementation has to make clear

User need

The product needs the original file for evidence, identity, compliance, media review, document processing, or support investigation.

Pattern promise

Provide a labelled file upload control that states requirements up front, uses a reliable file chooser, displays selected file details, validates type and size, shows progress and outcome, supports removal and retry, and preserves the surrounding task state.

Required state

Empty labelled state with requirements hint and choose-file action.

Failure to inspect

A failed upload clears other form answers or returns users to the start of the journey.

Access contract

Keep requirements in persistent hint text and associate them with the file input or upload button.

Quality bar

The difference between expert and weak execution

Strong implementation

Specific, visible, recoverable

  • An evidence upload field says Upload bank statement, hints PDF, PNG, or JPG up to 10 MB, shows statement.pdf selected, displays upload progress, and offers Remove.
  • A passport photo uploader shows the chosen filename, thumbnail-independent file details, an uploaded badge, and an inline error when the file is too large.
  • A user selects bank-statement.pdf, sees it queued, watches progress reach uploaded, removes it to choose another file, then submits after reviewing the rest of the form.
  • A user chooses image.heic, sees a precise wrong-type error, keeps the page state, chooses statement.pdf, retries after a simulated network failure, and continues.
Weak implementation

Vague, hidden, hard to recover from

  • A user selects a 28 MB scan, clicks Continue, and the page reloads with File failed but the selected filename and other answers are gone.
  • A failed upload clears other form answers or returns users to the start of the journey.
UI guidance
  • Render a visible label, persistent hint, native file chooser or equivalent button, accepted file formats, maximum file size, selected filename, uploaded status, remove control, and field-specific error message.
  • Distinguish selected, uploading, uploaded, failed, removed, and submitted states visually and in text so users know whether the file is merely chosen locally or actually attached to the service.
UX guidance
  • Use file upload only when the service needs the original file and make expectations clear before the user opens the file picker.
  • Let users select, review, remove, replace, retry, and continue without losing unrelated form answers or confusing upload completion with final submission.
Implementation contract

What the implementation must handle

States

  • Empty labelled state with requirements hint and choose-file action.
  • File chooser invoked state with focus returning to the upload control.
  • Uploading state with progress or pending indicator tied to the file.
  • Uploaded state showing successful attachment and replace or remove controls.

Interaction

  • Activating the choose-file button opens the platform file picker and returns focus to the invoking control or selected file summary afterward.
  • Selecting a file records filename, size, type, and local selected state before upload validation starts.
  • Client validation can warn about accepted types and size, but server validation remains authoritative.
  • Retrying a failed upload keeps the selected filename visible while the retry is pending.

Accessibility

  • Keep requirements in persistent hint text and associate them with the file input or upload button.
  • Return focus predictably after the native file picker closes.
  • Expose selected filename, status, remove action, retry action, and errors to assistive technology.
  • Avoid progress announcements that overwhelm screen reader users; announce meaningful state changes.

Review

  • Why does the service need the original file rather than a typed value?
  • What file types, sizes, count limits, password policies, and scanning delays will users encounter?
  • Can users tell whether the file is selected locally, uploading, uploaded, failed, removed, or included in final submit?
  • What happens if upload fails after the user has filled the rest of the form?
Evidence trail

Source-backed claims behind this guidance

GOV.UK Design System: File upload

Government Digital Service - checked

GOV.UK supports labelled file upload, hints, errors, critical-use guidance, multiple files, improved upload behavior, and count-limit messaging.

Carbon Design System: File uploader

IBM - checked

Carbon supports selected filename display, loading, success, uploaded, invalid states, removal, focus return, keyboard activation, and drop-zone boundaries.

MDN: input type=file

Mozilla - checked

MDN supports native file input behavior, FileList access, accept type specifiers, multiple selection, capture hints, and validation caveats.

DWP Design System research: File upload

Department for Work and Pensions - checked

DWP research supports expectation setting, upload understandability, user control, timely feedback, mobile edge cases, and upload-versus-submit clarity.

Full agent/debug reference

Problem Context

  • The product needs the original file for evidence, identity, compliance, media review, document processing, or support investigation.
  • Users may be on mobile devices, public computers, locked-down desktops, or assistive technology where drag-and-drop may not be available.
  • The file may fail because of type, size, malware scanning, password protection, interrupted network, duplicate attachment, or expired session.
  • The upload may happen immediately after selection or later with the form submit, and users need to understand which model is active.
  • The service must validate selected files server-side even when the client limits accepted extensions or MIME types.

Selection Rules

  • Choose file upload when the original file itself is needed, not just information from the file.
  • Use text input when a typed value, reference number, or explanation can replace the file.
  • Use a single-question page before upload when users first need to answer whether they have evidence or which evidence type applies.
  • Use a multi-step form when upload depends on earlier answers or is one saved step in a longer journey.
  • Use drag-and-drop upload only as an enhancement when button-based file selection remains available.
  • Use bulk import when the file contains structured rows that need parsing, mapping, validation, and an import report.
  • Avoid asking for an upload unless the file is critical to completing the service.
  • State accepted formats, maximum size, count limit, password-protected file policy, and whether photos or scans are acceptable.
  • Preserve selected filenames and unrelated answers after recoverable validation or network errors.
  • Make the upload-versus-submit boundary explicit when the surrounding form still needs final review.

Required States

  • Empty labelled state with requirements hint and choose-file action.
  • File chooser invoked state with focus returning to the upload control.
  • Selected but not uploaded state showing filename, size, type, and remove action.
  • Uploading state with progress or pending indicator tied to the file.
  • Uploaded state showing successful attachment and replace or remove controls.
  • Wrong file type error state with accepted formats repeated.
  • File too large error state with maximum size and current file size.
  • Upload failed state with retry and keep-file guidance.
  • Removed file state confirming no attachment is queued.
  • Submitted state clarifying that the upload is included with the completed form.

Interaction Contract

  • Activating the choose-file button opens the platform file picker and returns focus to the invoking control or selected file summary afterward.
  • Selecting a file records filename, size, type, and local selected state before upload validation starts.
  • Client validation can warn about accepted types and size, but server validation remains authoritative.
  • Removing a file clears only that attachment and does not erase other form values.
  • Retrying a failed upload keeps the selected filename visible while the retry is pending.
  • Submitting the surrounding task is blocked until required uploads are valid or the user chooses an allowed no-file path.
  • Status changes are announced without repeatedly reading long filenames or progress updates on every small percentage change.

Implementation Checklist

  • Define accepted extensions, MIME types, maximum size, count limit, scanning policy, duplicate handling, password-protected file handling, upload timing, and storage outcome before designing the control.
  • Use a visible label and persistent hint; connect hint, selected-file summary, status, and error text to the input or upload button.
  • Show selected filename, file size, upload state, uploaded result, remove action, retry action, and final included-in-submission state.
  • Validate type, size, count, empty required state, duplicate file, interrupted upload, virus scan, and server rejection with specific recoverable messages.
  • Keep other answers and selected filenames visible after validation errors and network retries.
  • Test keyboard selection, focus return, screen reader announcements, mobile camera/file sources, public-device privacy, browser Back, slow networks, timeout, and unsupported file formats.
  • Do not make drag-and-drop the only upload path; keep a normal file chooser available.

Common Generated-UI Mistakes

  • Asking for a file when a typed reference number or simple answer would be enough.
  • Showing selected filename as if the final service submission has already happened.
  • Hiding accepted formats and maximum file size until after the user fails.
  • Clearing the selected file and unrelated form answers after a recoverable error.
  • Using drag-and-drop as the only interaction path.
  • Relying on the accept attribute or filename extension as proof that the file is safe or valid.
  • Treating structured spreadsheet imports as ordinary attachments with no row-level feedback.

Critique Questions

  • Why does the service need the original file rather than a typed value?
  • What file types, sizes, count limits, password policies, and scanning delays will users encounter?
  • Can users tell whether the file is selected locally, uploading, uploaded, failed, removed, or included in final submit?
  • What happens if upload fails after the user has filled the rest of the form?
  • Can keyboard, screen reader, mobile, and public-computer users complete the upload path without drag-and-drop?
  • Does the backend validate the same type, size, count, scan, and required-file rules as the UI?
Accessibility
  • Use a visible label that names the file purpose, not only Browse or Choose file.
  • Keep requirements in persistent hint text and associate them with the file input or upload button.
  • Return focus predictably after the native file picker closes.
  • Expose selected filename, status, remove action, retry action, and errors to assistive technology.
  • Do not rely on color alone for upload progress, failure, success, or required state.
  • Avoid progress announcements that overwhelm screen reader users; announce meaningful state changes.
  • Provide a keyboard-accessible choose-file path even when drag-and-drop is also supported.
Keyboard Behavior
  • Tab reaches the upload control, selected-file remove button, retry button, and following form controls in order.
  • Enter or Space activates the choose-file button or custom upload trigger.
  • After file selection or cancellation, focus returns to the control or selected-file summary.
  • Enter or Space on Remove clears only the selected file and keeps focus near the upload area.
  • Submit with a required upload error moves focus to the upload field or error summary link.
  • Drag-and-drop enhancements must not remove normal keyboard file selection.
Variants
  • Single file upload
  • Multiple file upload
  • Evidence upload
  • Identity document upload
  • Photo upload
  • Upload with progress
  • Upload with scan pending state
  • Upload with retry
  • Upload with remove or replace
  • Upload before submit

Verification

Source trail checked:

Saved items