---
title: "Cleaning up uploaded form files"
manual: "Form"
version: "main"
permalink: "https://docs.typo3.org/permalink/typo3/cms-form:howtos-cleanup-upload-folders@main"
source: "I/HowTos/CleanupUploadFolders/Index.rst"
rendered: "2026-10-07T18:55:49+00:00"
---

# Cleaning up uploaded form files {#howtos-cleanup-upload-folders}

<!-- TODO: no Markdown rendering for "versionadded" -->

The form elements `FileUpload` and `ImageUpload` store uploaded files in
sub-folders named `form_<hash>`. These folders are placed in the upload folder
that the element property `saveToFileMount` defines, for example
`1:/user_upload/`.

The folders accumulate over time. Submitted forms and abandoned forms both
leave folders behind. The
[DeleteUploads finisher](https://docs.typo3.org/permalink/typo3/cms-form:concepts-finishers-deleteuploadsfinisher@main) only
removes files of successfully submitted forms.

The console command `vendor/bin/typo3 form:cleanup:uploads` 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](https://docs.typo3.org/permalink/typo3/cms-form:run-the-command@main)
-   [Arguments and options](https://docs.typo3.org/permalink/typo3/cms-form:arguments-and-options@main)
-   [Run the command regularly](https://docs.typo3.org/permalink/typo3/cms-form:run-the-command-regularly@main)

## Run the command {#howtos-cleanup-upload-folders-run}

Pass at least one upload folder as a combined folder identifier. If form
elements use different upload folders, pass all of them.

```bash
# 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 `--dry-run` or `--force`, the command asks for confirmation before it
deletes the folders.

## Arguments and options {#howtos-cleanup-upload-folders-reference}

-   **upload-folder**

    -   *Type:* string
    -   *Required:* true

    Combined identifier of an upload folder to scan, for example
    `1:/user_upload/`. Pass several folders as separate arguments.

-   **--retention-period / -r**

    -   *Type:* integer
    -   *Default:* `336`

    Minimum age in hours before a form upload folder is removed. The value
    must be at least `1`.

-   **--dry-run**

    -   *Type:* bool
    -   *Default:* `false`

    Lists the expired folders without deleting them.

-   **--force / -f**

    -   *Type:* bool
    -   *Default:* `false`

    Skips the confirmation question. The command sets this option
    automatically when it runs without interaction, for example with
    `--no-interaction` or in the scheduler.

## Run the command regularly {#howtos-cleanup-upload-folders-scheduler}

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.
