use TYPO3\CMS\Core\Utility\GeneralUtility; $fileSize = 1024; $formattedSize = GeneralUtility::formatSize($fileSize); echo $formattedSize; // Output: "1 KB"
use TYPO3\CMS\Core\Utility\GeneralUtility; $fileSize = 10485760; $formattedSize = GeneralUtility::formatSize($fileSize); echo $formattedSize; // Output: "10 MB"
use TYPO3\CMS\Core\Utility\GeneralUtility; $fileSize = 1234567890; $formattedSize = GeneralUtility::formatSize($fileSize); echo $formattedSize; // Output: "1.15 GB"The GeneralUtility class is part of the TYPO3 Core package library.