Cleaning up uploaded form files
New in version 14.2 Feature: #89951 - Cleanup command for form file upload folders
The form elements File and Image store uploaded files in
sub-folders named form_<hash>. These folders are placed in the upload folder
that the element property save defines, for example
1:/.
The folders accumulate over time. Submitted forms and abandoned forms both leave folders behind. The DeleteUploads finisher only removes files of successfully submitted forms.
The console command vendor/ removes old form
upload folders. Uploaded files are not moved when a form is submitted. The
command therefore cannot tell folders of submitted and abandoned forms apart.
It removes a folder if both of the following conditions are true:
- The folder name is
form_followed by exactly 40 hexadecimal characters. - The folder was last modified before the retention period. The default retention period is 336 hours (2 weeks).
The command only checks the direct sub-folders of the given upload folders.
Table of contents
Run the command
Pass at least one upload folder as a combined folder identifier. If form elements use different upload folders, pass all of them.
# List form upload folders older than 2 weeks without deleting them
vendor/bin/typo3 form:cleanup:uploads 1:/user_upload/ --dry-run
# Delete form upload folders older than 48 hours
vendor/bin/typo3 form:cleanup:uploads 1:/user_upload/ --retention-period=48
# Scan several upload folders
vendor/bin/typo3 form:cleanup:uploads 1:/user_upload/ 2:/custom_uploads/
# Delete without confirmation
vendor/bin/typo3 form:cleanup:uploads 1:/user_upload/ --force
# Show the age and the number of files of each folder
vendor/bin/typo3 form:cleanup:uploads 1:/user_upload/ --dry-run -v
Without -- or --, the command asks for confirmation before it
deletes the folders.
Arguments and options
-
- Type
- string
- Required
true
Combined identifier of an upload folder to scan, for example
1:/. Pass several folders as separate arguments.user_ upload/
-
- Type
- integer
- Default
336
Minimum age in hours before a form upload folder is removed. The value must be at least
1.
-
- Type
- bool
- Default
false
Lists the expired folders without deleting them.
-
- Type
- bool
- Default
false
Skips the confirmation question. The command sets this option automatically when it runs without interaction, for example with
--or in the scheduler.no- interaction
Run the command regularly
Run the command regularly to keep the upload folders clean, for example once a day or once a week. Use one of the following options:
- Create a task of type Execute console commands in the
scheduler and select
form:.cleanup: uploads - Add the command to a cron job on the server.