Fields

File Upload

File Upload is the field for selecting, restoring, and listing uploaded files.

Use this page to preserve the input attributes, hidden upload inputs, and summary containers used by the field.

Preview

Attributes

File Upload fields span a field wrapper, the real file input, and supporting hidden inputs or summary containers.

Field

AttributeDescriptionImportance
data-formie-field-handleStable field identity used by validation, conditions, and error renderingRequired

Field input

AttributeDescriptionImportance
name="fields[attachments][]"File input payload name for selected filesRequired
data-formie-inputGeneric Formie input marker included in normal outputRecommended
data-formie-file-inputFile upload selector used by the field moduleRequired for upload behavior
data-formie-input-idStable identifier used to match upload resultsRequired for upload behavior
data-formie-input-type="file"Server-rendered file-input type markerRecommended
data-formie-file-upload-keyExplicit event-matching key for upload responsesOptional
data-formie-file-limitFile-count validation limitOptional
data-formie-size-min-limitMinimum file size validation in MBOptional
data-formie-size-max-limitMaximum file size validation in MBOptional
data-formie-file-upload-hydrate-endpointOverride for uploaded asset hydrationOptional

Supporting elements

The file upload module also depends on a few adjacent elements:

Hidden inputs

AttributePurposeImportance
data-formie-file-upload-anchor="true"Stable insertion point for uploaded asset IDsRequired when uploads are synchronized back into hidden inputs
data-formie-file-upload-asset-id="true"Stored uploaded asset IDs for restored stateManaged by Formie

Field summary

AttributePurposeImportance
[data-formie-file-summary]Summary wrapper for uploaded filenamesRecommended
[data-formie-file-summary-container]Summary list containerRecommended
[data-formie-file-summary-item]Individual uploaded file labelRecommended

If a summary container is missing, Formie can create one after the file input. Hand-authored templates should still keep it explicit when possible so the server-rendered and browser-updated states match.

Behavior

File Upload manages more than the native <input type="file"> surface:

  • It validates file count and size limits from data-formie-file-limit, data-formie-size-min-limit, and data-formie-size-max-limit.
  • It listens for upload result payloads and synchronizes uploaded asset IDs into hidden inputs beside the file input.
  • It hydrates filename labels for stored asset IDs when only numeric asset references are initially available.
  • It resets both summary output and hidden asset inputs when the form emits formie:state:reset.

Events

File Upload emits a field event when uploaded asset ids have been synchronized back into the field state.

The formie:field:file-upload:uploaded-assets-sync event

Triggered after uploaded asset ids have been hydrated into the field state and the summary output.

js
document.addEventListener('formie:field:file-upload:uploaded-assets-sync', (event) => {
  const { fileUpload, assets } = event.detail;

  // Only target the attachments field.
  if (fileUpload?.dataset.formieFieldHandle !== 'attachments') {
    return;
  }

  // Reflect the current uploaded file count on the field wrapper.
  fileUpload.dataset.uploadedCount = String(assets.length);
});

Styling classes

These classes are for presentation only. They are not behavior requirements:

Field input

ClassDescription
formie-inputShared file-input styling and focus treatment
formie-file-inputFile Upload input styling class
formie-input-errorError-state styling class

Field summary

ClassDescription
formie-field-noteSummary note wrapper styling
formie-file-summarySummary wrapper for uploaded files
formie-file-summary-containerSummary list container
formie-file-summary-itemIndividual uploaded file label

Accessibility notes

  • Keep the file input explicitly labeled with the field label.
  • Summary output should remain close to the control so uploaded state is easy to review.
  • Error state should still apply through the surrounding field layout, not just the native file input.
Last updated: May 6, 2026, 3:46 PM