/** * Determine the max upload size based on PHP restrictions and config * * @param string $unit If '', determine the best unit based on the number * @param bool|false $humanReadable Return as a human readable filesize * * @return float */ public function getMaxUploadSize($unit = 'M', $humanReadable = false) { $maxAssetSize = $this->factory->getParameter('max_size'); $maxAssetSize = $maxAssetSize == -1 || $maxAssetSize === 0 ? PHP_INT_MAX : Asset::convertSizeToBytes($maxAssetSize . 'M'); $maxPostSize = Asset::getIniValue('post_max_size'); $maxUploadSize = Asset::getIniValue('upload_max_filesize'); $memoryLimit = Asset::getIniValue('memory_limit'); $maxAllowed = min(array_filter(array($maxAssetSize, $maxPostSize, $maxUploadSize, $memoryLimit))); if ($humanReadable) { $number = Asset::convertBytesToHumanReadable($maxAllowed); } else { list($number, $unit) = Asset::convertBytesToUnit($maxAllowed, $unit); } return $number; }