Make a check of file size a baked-in client side validation

Created on 15 July 2015, over 9 years ago
Updated 22 January 2024, 11 months ago

Problem/Motivation

Drupal's managed_file form #type allows files of any size to be sent to the server. A server-size limit exists, but the user is not informed of the issue until waiting for the possibly large file to be uploaded. Testing a file's size on the client prior to upload is totally doable in the majority of browsers currently in use, and it is possible to gracefully skip this check, falling back to the current behavior, on IE 8 and 9.

Proposed resolution

Make the following changes:

  • Determine the maximum allowed size for a given managed_file form element, including as configured on file field widgets, and include this amount as a data- attribute of the file input.
  • Add javascript to compare the size of files to this attribute, and prevent form submission if appropriate.

User interface changes

This implies a new validation error, originating in JavaScript, may be presented to the user. Its details would need to be worked out.

API changes

None anticipated

Data model changes

None anticipated

Beta phase evaluation

✨ Feature request
Status

Postponed

Version

11.0 πŸ”₯

Component
File systemΒ  β†’

Last updated 3 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States mbaynton Minneapolis, US

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.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update 11 months ago
    Patch Failed to Apply
  • πŸ‡ΈπŸ‡³Senegal diaodiallo

    Hi all,

    I am having this same issue with Drupal 10.2.0, when I upload a file which too large (150mb) than the maximum (10mb) nothing happen but was supposed to have error message that the file is larger than allowed. However a size like 15mb trigger the error message.

    Thanks for any helping idea.

Production build 0.71.5 2024