Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UploadedFile.php

function UploadedFile::parseFilesize

1 call to UploadedFile::parseFilesize()
UploadedFile::getMaxFilesize in vendor/symfony/http-foundation/File/UploadedFile.php
Returns the maximum size of an uploaded file as configured in php.ini.

File

vendor/symfony/http-foundation/File/UploadedFile.php, line 238

Class

UploadedFile
A file uploaded through a form.

Namespace

Symfony\Component\HttpFoundation\File

Code

private static function parseFilesize(string $size) : int|float {
    if ('' === $size) {
        return 0;
    }
    $size = strtolower($size);
    $max = ltrim($size, '+');
    if (str_starts_with($max, '0x')) {
        $max = \intval($max, 16);
    }
    elseif (str_starts_with($max, '0')) {
        $max = \intval($max, 8);
    }
    else {
        $max = (int) $max;
    }
    switch (substr($size, -1)) {
        case 't':
            $max *= 1024;
        // no break
        case 'g':
            $max *= 1024;
        // no break
        case 'm':
            $max *= 1024;
        // no break
        case 'k':
            $max *= 1024;
    }
    return $max;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal