Large File Uploads Fail Even When They Do Not Exceed The Max Upload Size

Created on 18 January 2023, almost 2 years ago
Updated 8 February 2023, almost 2 years ago

Large file uploads fail with browser status of 413

Steps to reproduce

Create a content type add a field for media type video or a contributed video upload field (doesn't matter type)
With media field type video it defaults to a maximum file upload based on "php.ini settings which is currently set at 6GB" for the site in question.

Go to add content select the new content type and try to upload a large video file (currently trying to upload a video that is 1.6GB and is an mp4 video type) which is well within the 6GB limit.

After several minutes the upload fails with the following error listed in web browser developer tools console:

Failed to load resource: the server responded with a status of 413 ()
Uncaught
Drupal.AjaxError {message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 41…     \\u003C\\/div\\u003E\\n    \\n","settings":null}]', name: 'AjaxError'}
     message: "\nAn AJAX HTTP error occurred.\nHTTP Result Code: 413\nDebugging information follows.\nPath: /node/add/product_post?element_parents=field_test_video/widget/0&ajax_form=1\nStatusText: error\nResponseText: \n413 Request Entity Too Large\nRequest Entity Too Large\nThe requested resource does not allow request data with POST requests, or the amount of data provided in\nthe request exceeds the capacity limit.\nApache/2.4.38 (Debian) Server at the.domain-name Port 80\n[{\"command\":\"add_css\",\"data\":\"\\u003Clink rel=\\u0022stylesheet\\u0022 media=\\u0022all\\u0022 href=\\u0022\\/core\\/themes\\/classy\\/css\\/components\\/messages.css?rooygs\\u0022 \\/\\u003E\\n\"},{\"command\":\"insert\",\"method\":\"prepend\",\"selector\":null,\"data\":\"\\n    \\u003Cdiv role=\\u0022contentinfo\\u0022 aria-label=\\u0022Error message\\u0022 class=\\u0022messages messages--error\\u0022\\u003E\\n          \\u003Cdiv role=\\u0022alert\\u0022\\u003E\\n                  \\u003Ch2 class=\\u0022visually-hidden\\u0022\\u003EError message\\u003C\\/h2\\u003E\\n                    An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (6 GB) that this server supports.\\n                \\u003C\\/div\\u003E\\n      \\u003C\\/div\\u003E\\n    \\n\",\"settings\":null}]"
   name:  "AjaxError"
   [[Prototype]]: Error at https://the.domain-name/core/misc/ajax.js?v=9.5.1:92:32 at https://the.domain-name/core/misc/ajax.js?v=9.5.1:642:3
      constructor:  Ζ’ (xmlhttp, uri, customMessage)
      stack:  "Error\n    at https://the.website-domain/core/misc/ajax.js?v=9.5.1:92:32\n    at https://the.website-domain/core/misc/ajax.js?v=9.5.1:642:3"
    [[Prototype]]: Object
  Drupal.Ajax.error	@	ajax.js?v=9.5.1:448
  complete	@	ajax.js?v=9.5.1:221
  M.complete.M.complete	@	jquery.form.min.js?v=4.3.0:22
  c	@	jquery.min.js?v=3.6.3:2
  fireWith	@	jquery.min.js?v=3.6.3:2
  l	@	jquery.min.js?v=3.6.3:2
  (anonymous)	@	jquery.min.js?v=3.6.3:2

NOTE: (and why this has to be a bug) On the same server a Drupal 7 site with a video upload field on a content type set to a max file size of 2GB and the "same 1.6GB .mp4" file uploads perfectly fine.

Here are the status page info as well as the php.ini info for the Drupal 9 website:
Drupal version 9.5.1
PHP version 8.1.13
Memory Limit 12288M
Web Server Apache/2.4.38 (Debian)
Database MySQL Version 5.7.40
-> If needed I can copy and past the entire page to this to include everything if needed?

Here is the php.ini info: (copied directly from the info page Drupal supplies)
max_execution_time 2048
max_file_uploads 100000
max_input_nesting_level 64
max_input_time -1
max_input_vars 200000
memory_limit 12288M
post_max_size 6144M
upload_max_filesize 6144M
-> If needed I can also copy and paste the entire page with everything included if needed?

There are no errors listed in Drupal's DBLog when this occurs, there is also nothing returned to the node/add page specifying an error! (which I feel there should be)

Now for comparison here is the Drupal 7 site Status page and php.ini details for comparison (as they are both live under different domains on the same server) "the Drupal 7 site does not have any problems with the same file"
Drupal version 7.94
PHP version 7.3.12
Memory Limit 4096M
Web Server Apache/2.4.25 (Debian)
Database MySQL version 5.6.43
-> again if needed I can copy and paste the entire status page with everything if needed?

Here is the php.ini info: (copied directly from the info page Drupal supplies)
max_execution_time 120
max_file_uploads 10000
max_input_nesting_level 64
max_input_time -1
max_input_vars 100000
memory_limit 4096M
post_max_size 2048M
upload_max_filesize 2048M
-> again I can also copy the entire info page if needed with everything?

Besides the max_upload, post and memory limit (as well as php versions) everything is virtually identical between Drupal 7 and Drupal 9 backend server setup, etc.

Drupal 9 is failing large file uploads and this is a major problem as I'm actually trying to rebuild the entire "working Drupal 7 site in Drupal 9 -> (migration isn't an option for how extensively the D7 site is customized)
- This issue is causing a major problem in trying to continue as large video uploads is an absolute requirement!

Again the same 1.6GB file that uploads to Drupal 7 just fine will not upload on Drupal 9 (as a core Media type video field or in a contributed module video field)

In Drupal 9 when uploading the media uploader field does say 6GB limit (and is set to allow .mp4 video file types)

If more information is needed and or screen shots please let me know as this is blocking continued development (and currently there are no core patches being applied) if there is a patch that addresses this I have not been able to find it

Apologies if this should be listed under another core component besides "file system" if it should be please update it to reflect the proper component.

πŸ’¬ Support request
Status

Fixed

Version

9.5

Component
File systemΒ  β†’

Last updated about 3 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States sidgrafix

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.

  • A cursory survey of Drupal Core and its dependencies indicates that Drupal does not emit HTTP 413 responses.

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

    Had to move onto other things for a while but finally figured it out...

    Had to add an apache2 directive to the apache2.conf configuration file (even tho according to apache documentation apache prior to 2.4.53 has a default value of unlimited for directive "LimitRequestBody") and shouldn't even be required being the problem version of apache here is 2.4.38 "Drupal 9 setup" (when it works without a problem on 2.4.25, not having the config directive, "Drupal 7 setup")

    By adding:
    LimitRequestBody 6073741824 at the end of the config file
    - Uploads up to 6GB can now occur (matching what was set in php settings)

    Per documentation apache 2.4.53 and later have the directive included and set to 1073741824 (as bytes) which is basically a hard limit around 1GB - apparently their documentation is not correct. Which can be found here: https://httpd.apache.org/docs/2.4/mod/core.html#limitrequestbody

    For future reference should someone run into this, it can also be set in .htaccess

    So this is not a Drupal 9 bug...(I would change the status of this issue but I don't see where I can in that respect!)

  • Assigned to sidgrafix
  • Status changed to Fixed almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States sidgrafix
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024