Error case missing on file size limit

Created on 24 May 2020, about 5 years ago
Updated 13 June 2025, about 2 months ago

My default installation has a 2MB max_file_size in the PHP settings. I created an image field for a content type that allowed 2MB images.
User attempted to upload 3MB file - and received a 'Max file size limit exceeded' message and reported the problem to me.
I changed the content field size to 4MB, flushed and attempted to upload 3MB image.
I received the same error message. When I changed the max_file_size limit in PHP the error message stopped.
Since the case is detecting the image size exceeds maximum, it should be capable of differentiating between whether the failure is the field limit or the PHP limit. In turn, the message should state that the field exceeds its content definition limits or the field exceeds the system limits.
It is possible this problem also exists on files besides images, I didn't stop to look but it seems likely this also exists on file fields as well.

I considered submitting this as a feature request, but I believe it technically falls under the bug category as a use case failure. My old QA days ...:)

🐛 Bug report
Status

Closed: works as designed

Version

11.0 🔥

Component

file system

Created by

🇺🇸United States jshimota01 Portland, OR

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.

  • 🇮🇳India mohit_aghera Rajkot

    I believe this issue doesn't exist anymore.

    Reasons:
    Right now we are displaying file upload help text like following image.

    The value 8 MB is coming from negotiation between what we defined in field setting and post_max_size & upload_max_filesize php.ini variables.
    Refer https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...

    Once we have the minimum file size upload value from above php.ini variables, we compare it with the value defined in field setting's file upload size setting.
    See https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/file/... for validator callback and for https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/file/... actual callback implementation.

    Here we decide what maximum file size should be allowed for users to upload and we set in validation constraint.

    // Cap the upload size according to the PHP limit.
        $maxFilesize = Bytes::toNumber(Environment::getUploadMaxSize());
        if (!empty($settings['max_filesize'])) {
          $maxFilesize = min($maxFilesize, Bytes::toNumber($settings['max_filesize']));
        }
    

    So essentially, user will always have the minimum possible file upload size and it will be calculated based on our settings and php.ini

    With this there is no need to show different message to users as it might be too technical for them.

    Feel free to reopen the issues if you notice further issues.

Production build 0.71.5 2024