Files are uploaded even when forms are not submitted

Created on 27 May 2022, about 2 years ago
Updated 4 March 2024, 4 months ago

Problem/Motivation

Selected in file/media upload forms get uploaded to the server even if you never submit the form. They are deleted if you use the "Remove" button, but if you don't then the files remain on the server, and its filename is no longer available for future use, presumably, forever.

As reported in ✨ Uploaded files are impossible to replace Active , you can never replace or delete these files without installing more contrib modules that you'd never want your users to have access to. The files are not even marked as temporary until the form is submitted, they just immediately become permanent files.

Steps to reproduce

  1. Make sure media module is enabled and go to /media/add, OR simply add a non-media file reference field to a content type and add a new node of that type
  2. Click the "browse" button of the file/media field and choose a file from your local machine
  3. Leave the page without submitting the form
  4. File remains in the Drupal file system forever, even after Cron runs, because the file is not a temporary file. Any attempt to re-upload a file with the same name causes the filename to increment. The original file cannot be deleted or replaced, and you have lost use of that filename.

Proposed resolution

Here are some options:

  1. Do not upload files until the form is submitted.
  2. Delete file immediately if a file is uploaded and then orphaned.
  3. Upload files to the temporary filesystem, then move after submit. This would require updating the file URL on submit.
πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
File systemΒ  β†’

Last updated about 22 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States chrisgross

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024