8.5.x file.inc file_upload_max_size()
8.0.x file.inc file_upload_max_size()
8.1.x file.inc file_upload_max_size()
8.2.x file.inc file_upload_max_size()
8.3.x file.inc file_upload_max_size()
8.4.x file.inc file_upload_max_size()
8.6.x file.inc file_upload_max_size()
4.7.x file.inc file_upload_max_size()
5.x file.inc file_upload_max_size()
6.x file.inc file_upload_max_size()
7.x file.inc file_upload_max_size()

Determines the maximum file upload size by querying the PHP settings.

Return value

A file size limit in bytes based on the PHP upload_max_filesize and post_max_size

Related topics

6 calls to file_upload_max_size()
EditorImageDialog::buildForm in core/modules/editor/src/Form/EditorImageDialog.php
editor_image_upload_settings_form in core/modules/editor/editor.admin.inc
Subform constructor to configure the text editor's image upload settings.
FileItem::fieldSettingsForm in core/modules/file/src/Plugin/Field/FieldType/FileItem.php
Returns a form for the field-level settings.
FileItem::getUploadValidators in core/modules/file/src/Plugin/Field/FieldType/FileItem.php
Retrieves the upload validators for a file field.
FormBuilder::getFileUploadMaxSize in core/lib/Drupal/Core/Form/FormBuilder.php
Wraps file_upload_max_size().

... See full list

File

core/includes/file.inc, line 1001
API for handling file uploads and server file management.

Code

function file_upload_max_size() {
  static $max_size = -1;
  if ($max_size < 0) {

    // Start with post_max_size.
    $max_size = Bytes::toInt(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 = Bytes::toInt(ini_get('upload_max_filesize'));
    if ($upload_max > 0 && $upload_max < $max_size) {
      $max_size = $upload_max;
    }
  }
  return $max_size;
}