Appearance
File Upload
A file upload field that handles file selection, validation, and upload to the WordPress media library. Returns the uploaded file's URL.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| name | text | '' | The field name. The uploaded file URL is stored under this key. |
| label | text | '' | The visible label displayed above the upload area. |
| accept | text | '' | Allowed MIME types, comma-separated (e.g., image/*, application/pdf). Empty allows all types. |
| maxSizeMb | number | 5 | Maximum file size in megabytes. |
| required | boolean | false | Whether a file must be uploaded for form submission. |
Events
onChange-- Fires when a file is selected or uploaded.
Example
An image upload:
name: photo
label: Upload Photo
accept: image/*
maxSizeMb: 10
required: trueA document upload:
name: resume
label: Upload Resume
accept: application/pdf,.doc,.docx
maxSizeMb: 5
required: trueTips
- Place inside a Form Container for the uploaded file URL to be included in form submissions.
- The uploaded file goes through WordPress's
wp_handle_upload()function, which applies all standard WordPress security checks. - The
acceptproperty restricts file selection in the browser's file picker. Always validate server-side too -- clients can bypass browser restrictions. - After a successful upload, the field value becomes the file's WordPress media library URL (e.g.,
https://example.com/wp-content/uploads/2024/01/photo.jpg). - Use the Image widget with
src: { {row.photo}}to display previously uploaded images. - For security, restrict
acceptto only the MIME types your app actually needs.