diff --git a/webfiori/file/FileUploader.php b/webfiori/file/FileUploader.php index 0b69066..cccf873 100644 --- a/webfiori/file/FileUploader.php +++ b/webfiori/file/FileUploader.php @@ -607,6 +607,27 @@ private function getFileArr($fileOrFiles,$replaceIfExist, ?string $idx): array { return $fileInfoArr; } + /** + * Returns the value of the directive 'upload_max_filesize' in KB. + * + * @return int + */ + public static function getMaxFileSize() : int { + $val = ini_get('upload_max_filesize'); + $lastChar = strtoupper($val[strlen($val) - 1]); + + switch ($lastChar) { + case 'M' : { + return intval($val) * 1000; + } case 'K' : { + return intval($val); + } case 'G' : { + return intval($val) * 1000000; + } default : { + return intval($val) / 1000; + } + } + } /** * Checks if PHP upload code is error or not. * @@ -625,7 +646,7 @@ private function isError(int $code): bool { return false; } case UPLOAD_ERR_INI_SIZE:{ - $this->uploadStatusMessage = 'File Size is Larger Than '.(intval(ini_get('upload_max_filesize')) / 1000).'KB. Found in php.ini.'; + $this->uploadStatusMessage = 'File Size is Larger Than '.(self::getMaxFileSize()).'KB. Found in php.ini.'; break; } case UPLOAD_ERR_PARTIAL:{