1

I have changed the upload_max_filesize and the max body size in my php.ini to 15 MB. It used to be 2 MB. Drupal displays the max file size correctly, but when I try to upload files bigger than 2 MB - the old limit - I get an Ajax Error, telling me the entity is too large. Any idea where this comes from?

  • 1
    Have you changed the same on your web server? – Clive Jan 15 '15 at 11:11
  • Ah, it might also need a change in my Apache? This is a good hint. Unfortunately I don't have access to the server config. Do you happen to know how I can check it in PHP? – stiller_leser Jan 15 '15 at 11:17
  • 2
    Yeah but only maybe :) Have you set all possible vars in php.ini? You can have: upload_max_filesize, post_max_size, and suhosin.post.max_value_length (if that's active). I believe both of the first two need to be set for things to take effect – Clive Jan 15 '15 at 11:20
  • They are both set to 15 MB. – stiller_leser Jan 15 '15 at 11:25
  • 1
    It could well need changing at web server level then, might be an idea to get in touch with your sysadmin and ask how to proceed – Clive Jan 15 '15 at 11:26
1

Just for documentation I'd like to add my findings here. I had this issue in Drupal 8, but I guess the Drupal version can be neglected to answer this question.


Suhosin

As @Clive already mentioned it in the comments to the question it's definitely worth a look under /admin/reports/status/php if the Suhosin PHP extension is enabled.

In https://www.drupal.org/node/725056 people suggest to disable this extension completely, but it's maybe better as @Clive suggested to simply override one of its parameters by editing your php.ini. Or by setting this in settings.php – if that is possible at all – via ini_set('suhosin.post.max_value_length', '-1'); or something like that. Maybe it's a different parameter you have to override.


Or Apache

If there's no Suhosin extension enabled, you may find this forum post valuable: https://www.drupal.org/forum/support/post-installation/2015-04-07/ajax-error-when-uploading-large-files where it's suggested to disable or reconfigure Apache's mod_security security mod.


Or JS

Last but not least you could simply try to circumvent Ajax completely by unbinding the event handler for the submit button, or by removing it completely.

Drupal 7

// Disable ajax upload for file field
drupal_add_js("jQuery(function() { jQuery('#edit-field-image :submit').unbind(); });", 'inline');

Source: How do I disable ajax on file fields?

Drupal 8

(function ($, Drupal) {
  Drupal.behaviors.autokill = {
    attach: function (context, settings) {
      // $('.form-managed-file > input.form-submit').remove();
      $submit_button = $('.form-managed-file > input.form-submit');
      $submit_button.unbind();
      $submit_button.removeClass('js-hide');
    }
  };
})(jQuery, Drupal);
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.