K

Fields

FileUpload

File upload with preview, validation, and image processing.

FileUpload preview

File upload with preview, validation, and image processing.

use NyonCode\WireForms\Components\FileUpload;

Basic Usage

FileUpload::make('attachment')
->disk('public')
->directory('attachments')

Validation

FileUpload::make('document')
->acceptedFileTypes(['application/pdf', 'image/*'])
->maxSize(10240) // KB
->minSize(100) // KB
->multiple()
->maxFiles(5)
->minFiles(1)

Image Mode

FileUpload::make('photo')
->image()
->imageResizeTargetWidth(1920)
->imageResizeTargetHeight(1080)
->imageCropAspectRatio('16:9')

Avatar

FileUpload::make('avatar')
->avatar() // circular preview, single file

Storage

FileUpload::make('file')
->disk('s3')
->directory('uploads/2024')
->visibility('public')
->preserveFilenames()

Methods

Method Description
disk(string) Storage disk
directory(string) Upload directory
visibility(string) File visibility (public, private)
preserveFilenames() Keep original filenames
acceptedFileTypes(array) Allowed MIME types
maxSize(int) Max file size in KB
minSize(int) Min file size in KB
multiple() Allow multiple files
maxFiles(int) Max number of files
minFiles(int) Min number of files
image() Image-only mode
avatar() Avatar mode (circular, single)
imageResizeTargetWidth(int) Resize width in pixels
imageResizeTargetHeight(int) Resize height in pixels
imageCropAspectRatio(string) Crop aspect ratio (e.g. 16:9)
disabled(bool|Closure) Disable the uploader
required() Mark as required

See Common Field API for label, hint, tooltip, and other shared methods.