From 16751de194ab913d61be50c569d8dbef1ee81386 Mon Sep 17 00:00:00 2001 From: SeNS Date: Thu, 27 Jun 2024 14:21:55 -0400 Subject: [PATCH] Update getFileList.php Added Kb & Gb for the file sizes --- getFileList.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/getFileList.php b/getFileList.php index 5f47283..dff5e25 100644 --- a/getFileList.php +++ b/getFileList.php @@ -52,7 +52,17 @@ foreach ($files as $file) { $fileSizeBytes = filesize($filePath); $fileDate = date(DATE_TIME_FORMAT, filemtime($filePath)); $uploadDate = date(DATE_TIME_FORMAT, filectime($filePath)); - $fileSizeFormatted = ($fileSizeBytes >= 1048576) ? sprintf("%.1f MB (%s bytes)", $fileSizeBytes / 1048576, number_format($fileSizeBytes)) : sprintf("%s bytes", number_format($fileSizeBytes)); + + if ($fileSizeBytes >= 1073741824) { + $fileSizeFormatted = sprintf("%.1f GB (%s bytes)", $fileSizeBytes / 1073741824, number_format($fileSizeBytes)); + } elseif ($fileSizeBytes >= 1048576) { + $fileSizeFormatted = sprintf("%.1f MB (%s bytes)", $fileSizeBytes / 1048576, number_format($fileSizeBytes)); + } elseif ($fileSizeBytes >= 1024) { + $fileSizeFormatted = sprintf("%.1f KB (%s bytes)", $fileSizeBytes / 1024, number_format($fileSizeBytes)); + } else { + $fileSizeFormatted = sprintf("%s bytes", number_format($fileSizeBytes)); + } + $fileUrl = BASE_URL . rawurlencode($file); $fileList[] = [ 'name' => htmlspecialchars($file, ENT_QUOTES, 'UTF-8'),