Function helper to get max file upload size in Bytes
<?php
namespace App\Infrastructure\Utilities;
class SystemUtil
{
public static function maxFileUploadSize()
{
//select maximum upload size
$maxUpload = self::getBytes(ini_get('upload_max_filesize'));
//select post limit
$maxPost = self::getBytes(ini_get('post_max_size'));
//select memory limit
$memoryLimit = self::getBytes(ini_get('memory_limit'));
// return the smallest of them, this defines the real limit
return min($maxUpload, $maxPost, $memoryLimit);
}
public static function getBytes($val)
{
$val = trim($val);
$last = strtolower($val[strlen($val)-1]);
switch($last)
{
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
}
}