Does FilamentPHP remove temporary uploads when validation fails?
0 reputation · 23 Dec 2023, 07:20 UTC
0 reputation · 23 Dec 2023, 07:20 UTC
Confirm whether FilamentPHP automatically deletes files staged in temporary storage when a form submission fails validation, and whether this behavior depends on the installed major release or the configured filesystem disk.
FilamentPHP delegates file uploads to Laravel's filesystem abstraction, but temporary-upload cleanup is not documented as guaranteed across local, S3, or custom disks. Behavior may differ between major versions, so the installed release should be treated as a variable rather than assumed.
What cleanup behavior should I expect after a validation failure? Does the temporary file persist on local disk but not on S3, or vice versa? Which Filament major version first changed this behavior?
35775 reputation · 23 Dec 2023, 09:48 UTC
No. FilamentPHP does not guarantee that temporary uploads are deleted when form validation fails. Files staged by a FileUpload field usually remain in temporary storage until Livewire removes them on a later cleanup cycle or until you delete them manually. This is not documented as behaving differently for local, S3, or custom disks, and no specific Filament major version is confirmed as the first to change this behavior.
Filament delegates uploads to Laravel's filesystem abstraction and Livewire's temporary upload handling. When validation fails, the request ends before the file is moved from the temporary staging location to its final disk. The staged file is therefore left behind. Livewire may remove old temporary files periodically, but immediate deletion on validation failure is not a documented guarantee.
composer show filament/filament | grep -i versions
storage/app/tmp/livewire-tmp or the path configured for Livewire temporary uploads. On S3 or a custom disk, list objects under the temporary upload prefix used by your filesystem configuration.Which Filament major version are you running? The cleanup recommendation may differ between v2 and v3, so the installed release changes where to look for version-specific hooks.
This answer assumes standard Filament FileUpload usage and default Livewire temporary upload handling. It does not cover custom upload handlers or overridden disk configurations. Treat S3 and custom disk behavior as unverified; local temp files are easier to inspect, while S3 objects may persist under a temporary prefix without obvious filesystem signals. Verify against your installed release before relying on any cleanup automation.
Use comments to ask for clarification. Post a solution as an answer.
6,300 reputation · 23 Dec 2023, 17:34 UTC
Filament does not guarantee deletion of staged uploads merely because validation failed. In Filament 3.x, uploads are typically staged on the configured temporary filesystem disk before final storage, and cleanup is usually handled by application code, a scheduled job, or disk garbage collection rather than the validation cycle. Local and S3 disks can both retain staged objects unless explicit cleanup exists.
To verify, submit an invalid file upload, identify the temporary disk in config/filesystems.php, then inspect that disk with Laravel's Storage facade after the failed response. If the file remains, add targeted cleanup in your validation-failure handler or scheduler.