No warning when uploading media that is larger than limit (HTTP code 413)

Created on 8 February 2019, almost 6 years ago
Updated 27 January 2023, almost 2 years ago

Problem/Motivation

When uploading a new media that is larger than the limit set to the field - no warning appears on the admin interface.

There is an error message in console -

AjaxError: 
An AJAX HTTP error occurred.
HTTP Result Code: 413
Debugging information follows.
Path: /admin/content/media-widget-upload?media_library_widget_id=field_media-&media_library_allowed_types=&media_library_remaining=-1&_wrapper_format=drupal_modal&ajax_form=1
StatusText: Request Entity Too Large
ResponseText: 

413 Request Entity Too Large

413 Request Entity Too Large

nginx/1.15.3

ajax.js:98:32

Proposed resolution

Display a warning message to the user that he cannot upload a file that is bigger than the maximum file size allowed.

Steps to recreate the issue

1. Install Drupal 8.7.x Standard installation
2. Add Media library module
3. Add Media field to Article content Type
4. Add new Article
5. In media field - upload file that is bigger than 100MB

πŸ› Bug report
Status

Active

Version

10.1 ✨

Component
File systemΒ  β†’

Last updated about 10 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States shaal Boca Raton, FL

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.

  • πŸ‡ΊπŸ‡ΈUnited States tstermitz Colorado

    Suggestion #10 worked for me, however...

    I had to add the directive in two locations, the main server block and also the Location PHP block.

  • πŸ‡ΊπŸ‡ΈUnited States douggreen Winchester, VA

    I tested this on 8.9.x, 9.5.x, and 10.1.x before finding this issue. At first I thought this was a regression, because we have a test for it (MaximumFileSizeExceededUploadTest.php) which was added in #1489692: Incorrect handling of file upload limit exceeded - file widget disappears β†’ . However the test seems to not catch this (I couldn't get it to run locally on my Apple M1 chip under ddev).

    This is easy to reproduce with standard core + media module, try to upload a document that is more than the max upload size (100M by default if using ddev). The upload fails silently. A page refresh shows no warnings.

  • πŸ‡ΊπŸ‡ΈUnited States douggreen Winchester, VA

    The comment about it being a bad configuration in #10 is wrong IMO. Someone will always try to upload a file that's larger than the configured system, and we shouldn't fail silently. Additionally, there are many hosts where you can't increase this value, and it will never be unlimited. A previous posted mentioned that Acquia frequently had this problem. We have this problem on Pantheon with a 150M file and a 100M limit. I think it's reasonable to have a limit but not reasonable to fail silently to the user.

  • πŸ‡ΊπŸ‡ΈUnited States philosurfer

    I like the idea of an ajax capturing the 413 response and overlaying it with an option to view full raw response string.

  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

    An issue was recently committed that shows messages for AJAX errors:

    Can we verify if this helps resolve the issue, or can serve as a foundation/example for improvement here

  • We had the same issue while uploading the large files. The culprit was the client_body_buffer_size setting. It was set to 200MB. Basically, the buffer was too big and nginx was not able to allocate so much memory for keeping the file inside it. We had to lower the buffer to a normal value, so that file is buffered to a temp file during upload and the issue was resolved. Here is a detailed explanation.

  • πŸ‡²πŸ‡¦Morocco b.khouy πŸ‡²πŸ‡¦ Morocco

    The issue generally occurs when you try to upload a file that exceeds the post_max_size setting in PHP configuration. Here’s a summary:

    • If UploadedFileSize <= upload_max_filesize, the file will upload successfully.
    • If upload_max_filesize < UploadedFileSize <= post_max_size, a validation error message will appear.
    • If UploadedFileSize > post_max_size, nothing happens (which is the current issue being discussed).
Production build 0.71.5 2024