Cleanup
The storage helpers delete staged uploads after a successful operation. A failed operation keeps its files for a retry, and uploads that are never submitted stay on disk. Schedule the cleanup command as a safety net for both cases:
// In app/Console/Kernel.php or routes/console.php...
use Illuminate\Support\Facades\Schedule;
Schedule::command('form:cleanup-uploads')->hourly();The command deletes temporary upload directories older than file_uploads.temporary_uploads.lifetime, which defaults to one hour. You may pass another lifetime in seconds:
php artisan form:cleanup-uploads --lifetime=7200Which Disks Are Swept
The command only deletes inertia-forms-upload-* directories on these disks:
- The
file_uploads.temporary_uploads.diskdisk. An empty value uses the local staging disk. - The
file_uploads.direct_to_storage.diskdisk. An empty value uses thes3disk. - Every disk listed in
file_uploads.cleanup_disks. - Every disk passed with the
--diskoption, which may be repeated.
The command doesn't discover per-field disks from directToStorage('media') or uploadDisk('media') automatically. Add them to file_uploads.cleanup_disks:
// config/inertia-forms.php
return [
'file_uploads' => [
'cleanup_disks' => ['media', 'documents'],
],
];You may also pass them for one command run with repeated --disk options:
php artisan form:cleanup-uploads --disk=media --disk=documentsExpiration uses the newest file in each directory, so active chunked or multipart uploads remain. One inaccessible disk doesn't prevent the command from sweeping the remaining disks.
For S3-compatible direct-to-storage uploads, also configure bucket lifecycle rules that expire abandoned inertia-forms-upload-* objects and abort incomplete multipart uploads. S3 doesn't show a multipart session as an ordinary object until it completes.