in includes/file.inc, near line 744, the following is found:

  if ($max_size < 0) {
    $upload_max = _file_convert_to_mb(ini_get('upload_max_filesize'));
    // sanity check- a single upload should not be more than 50% the size limit of the total post
    $post_max = _file_convert_to_mb(ini_get('post_max_size')) / 2;
    $max_size = ($upload_max < $post_max) ? $upload_max : $post_max;
  }

This setting should be reflected somewhere in the Admin > upload settings.

In cases like the Project Module (especially with Project Release as Node), file attachment very often can be far larger than the short description associated with the release. For releases distributed in binary form, attachments can easily be 10s of megabytes, resulting in awkward post_max_size values.

Above code exposes PHP post_max_size must be DOUBLE upload_max_filesize or Admin > upload settings will be rejected.

Comments

jherteng’s picture

Title: Upload filesizes limited by php post_max_size, not upload_max_filesize » Upload filesizes limited by php post_max_size *and* upload_max_filesize

both post_max_size and upload_max_filesize must be in accordance... not just one or the other.

pwolanin’s picture

I wrote the validation code you're referring to. The factor of two was an arbitrary choice, but seemed reasonable since a single node can have multiple attachments. However, I'm not sure this choice is clearly documented - I'll add a note to http://drupal.org/handbook/modules/upload/ and I'll add a child page to http://drupal.org/node/363 covering this like changing memory site is covered.

If you think this should be in the help text for the upload module (/admin/help/upload), then we'll need a patch for 5.x and 4.7.x.

pwolanin’s picture

Version: 4.7.4 » 5.x-dev

changing version to 5.x, since this is present there as well.

Note that the PHP default value for POST_MAX_SIZE is 8 MB, while for UPLOAD_MAX_FILESIZE the default value is 2 MB. So, any site running with default PHP settings will get a 2 MB limit.

pwolanin’s picture

For details on these PHP directives, see: http://us3.php.net/manual/en/ini.core.php

I spent a while trying to figure out an appropriate validation behavior. Note also that the memory_limit can also become a limitiation for upload size.

See also this new handbook page: http://drupal.org/node/97193

mlncn’s picture

Version: 5.x-dev » 7.x-dev
Component: upload.module » documentation

The need to double post_max_size is not reflected in the handbook page itself?

That page needs a version or rewrite for Drupal 7, and it looks like creating and linking off to a dedicated troubleshooting page would make sense.

jhodgdon’s picture

Project: Drupal core » Documentation
Version: 7.x-dev »
Component: documentation » Correction/Clarification

Moving this to the Documentation issue queue, since it seems now to be related to on-line documentation.

jcisio’s picture

Status: Active » Fixed

Look at the current code, there is no need to double post_max_size.

/**
 * Determine the maximum file upload size by querying the PHP settings.
 *
 * @return
 *   A file size limit in bytes based on the PHP upload_max_filesize and
 *   post_max_size
 */
function file_upload_max_size() {
  static $max_size = -1;

  if ($max_size < 0) {
    // Start with post_max_size.
    $max_size = parse_size(ini_get('post_max_size'));

    // If upload_max_size is less, then reduce. Except if upload_max_size is
    // zero, which indicates no limit.
    $upload_max = parse_size(ini_get('upload_max_filesize'));
    if ($upload_max > 0 && $upload_max < $max_size) {
      $max_size = $upload_max;
    }
  }
  return $max_size;
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.