You are here

function _file_convert_to_mb in Drupal 4

Helper function for file_upload_max_size().

Related topics

1 call to _file_convert_to_mb()
file_upload_max_size in includes/file.inc
Determine the maximum file upload size by querying the PHP settings.

File

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

Code

function _file_convert_to_mb($val) {
  $val = trim($val);
  $last = strtolower($val[strlen($val) - 1]);
  switch ($last) {

    // The 'G' modifier is available since PHP 5.1.0
    case 'g':
      $size = $val * 1024;
      break;
    case 'k':
      $size = $val / 1024;
      break;
    default:
      $size = (int) $val;
  }
  return $size;
}