/** * 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; }
public function getMaxUploadFileSize() { $max_upload = \Mautic\AssetBundle\Entity\Asset::getIniValue('upload_max_filesize'); $max_post = \Mautic\AssetBundle\Entity\Asset::getIniValue('post_max_size'); $memory_limit = \Mautic\AssetBundle\Entity\Asset::getIniValue('memory_limit'); $upload_mb = min(array_filter([$max_upload, $max_post, $memory_limit])); $this->__log(__METHOD__ . ' - max upload file size is ' . $upload_mb . 'Mb'); return $upload_mb; }