Basic Usage
With Model Binding
HasMedia interface, the component automatically retrieves and displays the file from the media library.
File Types
Custom Validation
Spatie Media Library Integration
The File component integrates seamlessly with Spatie Media Library:Model Setup
Your model should implement theHasMedia interface:
File Display
Hints and Help Text
Attributes
The name attribute for the file input
Label text for the file input. Auto-generated from name if not provided
File type category. Accepts:
document, image, or array of types. Automatically determines allowed mime typesAllowed mime types. Overrides automatic detection from
type. Examples: application/pdf, image/jpegAllowed file extensions. Overrides automatic detection from mime types. Example:
['pdf', 'doc', 'docx']Maximum file size in kilobytes. Defaults to system default for the file type
Spatie Media Library collection name. Defaults to the input name
Spatie Media Library conversion name to display. Example:
thumbAdditional CSS classes for the file input wrapper
Icon class for the clear/remove button. Uses framework default if not specified
Icon class for the download link. Framework default:
fa-arrow-to-bottom (Bootstrap 5) or zmdi-open-in-new (Material Admin)Icon class for the upload button. Framework default:
fa-arrow-to-top (Bootstrap 5) or zmdi-upload (Material Admin)Model instance to bind to. Automatically retrieves file from media library if model implements
HasMediaDefault file URL if no value is bound
Show automatic hint with allowed file types and max size
Show validation errors
Show the label
Mark the field as required
Disable the file input
Ignore model accessors when retrieving value. Only retrieve from media library
Display label and input inline (horizontal layout)
Custom help text. Overrides automatic hint
Default File Types
The component automatically detects mime types based on thetype attribute:
- document: PDF, JPEG, PNG files (default)
- image: JPEG, PNG, GIF, TIFF, SVG files
AllowedMimeTypes helper from the javaabu/helpers package.
File Validation
The component renders theaccept attribute with allowed mime types: