File Upload Fields

Upload single or multiple files with validation for size, type and quantity. Supports dedicated image uploads.

Overview

Polyform has three file upload field types: file for single uploads, multi_file for multiple uploads and image for image-specific uploads. All three are validated by the FileFieldValidator, which handles size limits, extension filtering and storage.

Basic File Upload

Use addFile() to add a single file upload field.

app/Actions/CreateSurveyForm.php

Multiple File Upload

addMultiFile() lets users upload several files at once. Use maxFiles() to cap the number of uploads.

app/Actions/CreateApplicationForm.php

Image Upload

addImage() is a file upload tailored for images. It sets the HTML accept attribute to filter for image types in the file picker.

app/Actions/CreateProfileForm.php

Available Settings

SettingTypeDefaultDescription
max_size_kbinteger10240Maximum file size in kilobytes. Default is 10MB.
allowed_extensionsarray[]Array of allowed file extensions (e.g., ["pdf", "jpg"]). Empty allows all.
max_filesinteger5Maximum number of files for multi_file type only.
acceptstringnullHTML accept attribute for image type (e.g., "image/*").

Validation

The FileFieldValidator checks:

  • File size against the max_size_kb setting
  • File extension against the allowed_extensions array
  • Number of files against max_files (for multi_file type)
  • Required/optional status based on field configuration