Return the max upload size in bytes
@return int
350818
public static function getMaxUploadSize()
    {
        if (!ini_get('file_uploads')) {
            return 0;
        }

        $max = 0;

        try {
            $max = FormUtils::sizeToBytes(ini_get('upload_max_filesize'));
        } catch (\Exception $e) {
        }

        try {
            $max2 = FormUtils::sizeToBytes(ini_get('post_max_size'));
            if ($max2 < $max || $max == 0) {
                $max = $max2;
            }
        } catch (\Exception $e) {
        }

        return $max;
    }
745431
public function isValidSize()
    {
        // If file was blocked via PHP for being excessive size, shortcut here
        switch ($this->tmpFile['error']) {
            case UPLOAD_ERR_INI_SIZE:
            case UPLOAD_ERR_FORM_SIZE:
                return false;
        }
        $maxSize = $this->getAllowedMaxFileSize($this->getFileExtension());
        return (!$this->tmpFile['size'] || !$maxSize || (int)$this->tmpFile['size'] < $maxSize);
    }
262878
public function getSizeLimit()
    {
        // Get the lowest between post_max_size and upload_max_filesize, log a warning if the first is < than the latter
        $limit = $this->sizeToBytes(ini_get('upload_max_filesize'));
        $postLimit = $this->sizeToBytes(ini_get('post_max_size'));
        if ($postLimit > 0 && $postLimit < $limit) {
            Yii::warning('PHP.ini\'s \'post_max_size\' is less than \'upload_max_filesize\'.', __METHOD__);
            $limit = $postLimit;
        }
        if ($this->maxSize !== null && $limit > 0 && $this->maxSize < $limit) {
            $limit = $this->maxSize;
        }

        if (($request = Yii::getApp()->getRequest()) instanceof \yii\web\Request) {
            $maxFileSize = Yii::getApp()->getRequest()->getParsedBodyParam('MAX_FILE_SIZE', 0);
            if ($maxFileSize > 0 && $maxFileSize < $limit) {
                $limit = (int)$maxFileSize;
            }
        }

        return $limit;
    }
334673
private static function getUploadMaxFileSizeInBytes() {
    $val = trim(ini_get('upload_max_filesize'));
    $unit = strtolower(substr($val, -1));
    switch ($unit) {
      case 'g':
        $val *= 1024;
        // Fall through
      case 'm':
        $val *= 1024;
        // Fall through
      case 'k':
        $val *= 1024;
        break;
    }
    return intval($val);
  }
963507
private function getMaxWidth()
    {
        $max = 0;

        foreach ($this->getOptions() as $option) {
            $nameLength = \strlen($option->getName()) + 2;
            if ($option->getShortcut()) {
                $nameLength += \strlen($option->getShortcut()) + 3;
            }

            $max = \max($max, $nameLength);
        }

        foreach ($this->getArguments() as $argument) {
            $max = \max($max, \strlen($argument->getName()));
        }

        return ++$max;
    }
206256
public function remainingBytes(): int
    {
        /** @var array $stat */
        $stat = \fstat($this->fp);
        /** @var int $pos */
        $pos = \ftell($this->fp);
        return (int) (
            PHP_INT_MAX & (
                (int) $stat['size'] - $pos
            )
        );
    }
784329
protected function uploadArchive()
    {

        if ($_FILES['content']['error'] !== UPLOAD_ERR_OK) {

            \common_Logger::w('File upload failed with error ' . $_FILES['content']['error']);
            switch ($_FILES['content']['error']) {
                case UPLOAD_ERR_INI_SIZE:
                case UPLOAD_ERR_FORM_SIZE:
                    $error = __('Archive size must be lesser than : ') . ini_get('post_max_size');
                    break;
                case UPLOAD_ERR_NO_FILE:
                    $error = __('No file uploaded');
                    break;
                default:
                    $error = __('File upload failed');
                    break;
            }
            return array('error' => $error);
        }

        $filePath = $this->tmpDir . '/' . $_FILES['content']['name'];
        if (!move_uploaded_file($_FILES['content']['tmp_name'], $filePath)) {
            return array('error' => __('Unable to move uploaded file'));
        }

        return $filePath;
    }
101232
public function convertToByte()
        {
            $type = $this->getType();
            $size = $this->getSize();
            $selectedType = $this->sizeTypes[$type];

            return ($selectedType * $size);
        }
1279856
public static function getMaxAllowedPacket(): int
  {
    if (!isset(self::$maxAllowedPacket))
    {
      $query              = "show variables like 'max_allowed_packet'";
      $max_allowed_packet = self::executeRow1($query);

      self::$maxAllowedPacket = $max_allowed_packet['Value'];

      // Note: When setting $chunkSize equal to $maxAllowedPacket it is not possible to transmit a LOB
      // with size $maxAllowedPacket bytes (but only $maxAllowedPacket - 8 bytes). But when setting the size of
      // $chunkSize less than $maxAllowedPacket than it is possible to transmit a LOB with size
      // $maxAllowedPacket bytes.
      self::$chunkSize = (int)min(self::$maxAllowedPacket - 8, 1024 * 1024);
    }

    return (int)self::$maxAllowedPacket;
  }
167167
public function getNormalizeResponseChunkSize() : int
    {
        $chunkSize      = $this->getConfiguration('responseChunkSize', static::DEFAULT_CHUNK_SIZE);
        $chunkSize      = ! is_numeric($chunkSize) ? static::DEFAULT_CHUNK_SIZE : intval(abs($chunkSize));
        $chunkSize      = $chunkSize < 512 ? 512 : $chunkSize;
        return $chunkSize;
    }
1229198
function getSize()
    {
        $size = $this->_t__wrap_stream->getSize();
        if ($size !== null) {
            $segmentSize = $size - $this->getSegmentOffset();
            $size = ($this->getSegmentLimit() == -1)
                ? $segmentSize
                : min($segmentSize - $this->getSegmentLimit(), $this->getSegmentLimit());
        }

        return $size;
    }
303318
public function getMaxLength()
    {
        if ($this->isString() && isset($this->methodParams[0])) {
            return intval($this->methodParams[0]);
        }

        return null;
    }
1226810
public function getMaxFileSize(): int
    {
        if ($this->maxFileSize === null) {
            $value = ini_get("upload_max_filesize");
            $units = "BKMGT";
            $unit = preg_replace("/[^$units]/i", "", $value);
            $value = floatval($value);
            if ($unit) {
                $value *= pow(1024, stripos($units, $unit[0]));
            }
            $this->maxFileSize = (int) $value;
        }
        return $this->maxFileSize;
    }
977068
public function maxLength()
    {
        if ($this->maxLength === null) {
            $this->maxLength = $this->defaultMaxLength();
        }

        return $this->maxLength;
    }
1203436
public function size():int
    {
        if ($this->file == null) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Cannot get size for unopened file",
                "solution" =>
                    "Please open the file with [FileListener::open] before trying to get the size.")));
        }
        return (filesize($this->filepath));
    }
1173142
public function fullByteSize()
    {
        $size = $this->byteSize();
        foreach ($this->members as $variable) {
            $size += $variable->fullByteSize();
        }
        return $size;
    }
1254831
public static function getMaxUploadSize($maxSize = null)
    {
        $maxUpload = (int)(ini_get('upload_max_filesize'));
        $maxPost = (int)(ini_get('post_max_size'));
        $memoryLimit = (int)(ini_get('memory_limit'));
        $min = min($maxUpload, $maxPost, $memoryLimit);
        if ($maxSize) {
            $maxSize = (int)$maxSize;
            return min($maxSize, $min);
        }
        return $min;
    }