A Filament file upload field fails or shows no file on S3
The upload bar fails or the file is rejected for larger filesShort answer
A Filament upload goes first to Livewire's temporary storage and only then to your S3 disk. Large files hit Livewire's 12MB default or PHP's upload_max_filesize. Saved files can still not open because the disk name makes them private, or the browser is blocked by missing CORS headers on the bucket.
Fix it fast
1Find out which cause you have
Try a tiny file first. If it works, the cause is a size limit; if it saves but will not open, look at visibility and CORS.
php artisan config:show livewire php -r "echo ini_get('upload_max_filesize'), PHP_EOL;"2Match what you see, then jump to its fix
- 1
Files above about 12MB fail while small ones upload.Larger files exceed Livewire's default limitFix - 2
Even after raising Livewire's rule, the larger upload still fails.PHP's own upload limit is smallerFix - 3
The object exists in the bucket but the saved file cannot be viewed.The file is private, so its link does not openFix - 4
The browser console shows a cross-origin block when the preview loads.The bucket sends no CORS headersFix
- 1
What does the error look like?
The upload bar fails or the file is rejected for larger filesThe file is saved to S3 but its preview or link does not openPreviews fail in the browser console with a cross-origin error
Cause 1 of 4
Larger files exceed Livewire's default limit
1Check
Livewire validates every temporary upload with a default of max 12MB, and the limit is set in the rules key of temporary_file_upload.
php artisan livewire:publish --config2Fix
Raise the limit in config/livewire.php; the value is in kilobytes.
'temporary_file_upload' => [
'rules' => ['file', 'max:102400'], // 100MB
],3Verify
Upload a file between 12MB and the new limit.
php artisan config:show livewireConfirmed by livewire.laravel.com
Cause 2 of 4
PHP's own upload limit is smaller
1Check
Filament's docs point to php.ini upload_max_filesize as the other limit for failing large uploads.
php -i | grep -E "upload_max_filesize|post_max_size"2Fix
Raise it in the php.ini used by PHP-FPM, then restart PHP-FPM.
; php.ini
upload_max_filesize = 120M3Verify
Read the value back from the web SAPI, not only the CLI.
sudo systemctl restart php8.3-fpmConfirmed by filamentphp.com
Cause 3 of 4
The file is private, so its link does not open
1Check
Filament uploads with private visibility unless the disk is named public, and it decides this by the disk's name, not its filesystem config.
grep -rn "FileUpload::make" app/2Fix
Set visibility on the field explicitly for your S3 disk, or use temporary URLs if the files should stay private.
FileUpload::make('attachment')
->disk('s3')
->directory('form-attachments')
->visibility('public')3Verify
Create a new upload and open its link.
grep -rn "visibility" app/Confirmed by filamentphp.com
Cause 4 of 4
The bucket sends no CORS headers
1Check
The Filament docs say that if files are hosted on a separate domain such as S3, CORS headers must be set up.
aws s3api put-bucket-cors --help2Fix
Add a CORS rule to the bucket that allows your app's origin.
aws s3api put-bucket-cors --bucket my-bucket --cors-configuration file://cors.json3Verify
Reload the form and check the browser console no longer shows the cross-origin error.
cat cors.jsonConfirmed by filamentphp.com
How do I stop it coming back?
- Decide the upload limit once and set Livewire's rules, upload_max_filesize and post_max_size together.
- Set visibility on every FileUpload that uses a custom disk name.
- Keep the bucket CORS rule in version control.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Laravel cannot find League\Flysystem\AwsS3v3\AwsS3Adapter
Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found
The S3 adapter package is missing, or your code names the class from an older Flysystem.
2 causes, each with a fixBack end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fix