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.
Configurable Storage
File storage is handled by the FileStorageHandler contract, which can be swapped via
config('polyform.file_storage.handler'). By default, files go to Laravel's storage system on the configured disk. 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
Validation
The FileFieldValidator checks:
- File size against the
max_size_kbsetting - File extension against the
allowed_extensionsarray - Number of files against
max_files(for multi_file type) - Required/optional status based on field configuration
File Size Limits
Make sure your server's
upload_max_filesize and post_max_size PHP settings match or exceed your form's file size limits.