private function formatSize($bytes) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); $pow = $bytes ? floor(log($bytes, 1024)) : 0; $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return number_format($bytes, 2) . ' ' . $units[$pow]; }