You are here

function _filefield_maximum_filesize in FileField 6.2

Get the maximum file size that is allowed for a new upload.

Return value

-1 for "no more files allowed", or any positive value as the number of bytes that may still be uploaded. A result of 0 ("unlimited") will never happen because of PHP's upload limits.)

1 call to _filefield_maximum_filesize()
_filefield_filefield_validators in ./filefield.widget.inc
Implementation of hook_filefield_validators(): Upload restrictions for file size, file extension and supported file widgets. Implemented as private function instead of as a real hook, because we want to make an exception so that these requirements…

File

./filefield.widget.inc, line 391
FileField: Defines a CCK file field type.

Code

function _filefield_maximum_filesize($field, $widget, $existing_files) {

  // Calculate the maximum file size - the least of all returned values.
  $max_filesize = FALSE;
  $restrictions = module_invoke_all('filefield_filesize_restrictions', $field, $widget, $existing_files);
  foreach ($restrictions as $value) {
    if ($max_filesize === FALSE || $value < $max_filesize) {
      $max_filesize = $value;
    }
  }

  // Return -1 if any restriction value was not a positive number.
  if ($max_filesize === FALSE || $max_filesize <= 0) {
    return -1;
  }
  return $max_filesize;
}