© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
9 replies
The Milkman

Why does FileUpload not respect ->rules() ?

It seems that when specifying rules to a FileUpload field, it is not validated. Is that expected behaviour?

FileUpload::make('csv_file')
    ->label(__('CSV File'))
    ->rules(['mimes:csv,txt']) // This allows images just fine
FileUpload::make('csv_file')
    ->label(__('CSV File'))
    ->rules(['mimes:csv,txt']) // This allows images just fine


I know I probably should use
->acceptedFileTypes()
->acceptedFileTypes()
for this, but I actually want to validate the input on WOFF and WOFF2 font files.
Since acceptedFileTypes uses the front-end validator of Filepond, I can't use this, because browsers cannot resolve the correct mimetypes for these files...

So, I need to do some serverside validation. But how?
Solution
I've made PR for this: https://github.com/filamentphp/filament/pull/13814
GitHub
Add better mimetype support for FileUpload component by bbredewold ...
Description
This PR adds better front-end filetype validation to the FileUpload field.
The FileUpload field uses Filepond for uploading files.
When setting ->acceptedFileTypes() with the accepte...
Add better mimetype support for FileUpload component by bbredewold ...
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Fileupload does not render file
FilamentFFilament / ❓┊help
4w ago
Stack component does not seem to respect `alignment`
FilamentFFilament / ❓┊help
2y ago
Toggle in Action does not respect default state
FilamentFFilament / ❓┊help
3y ago
getUploadedFileNameForStorageUsing() on FileUpload::configureUsing() does not work :S
FilamentFFilament / ❓┊help
2y ago