How can PHP be used to display the amount of storage space used on a website for user uploads?
To display the amount of storage space used on a website for user uploads, you can calculate the total size of all uploaded files on the server using PHP. This can be achieved by iterating through the upload directory and summing up the file sizes. Finally, you can display this information to the user on a webpage.
<?php
$uploadDir = 'uploads/';
$files = glob($uploadDir . '*');
$totalSize = 0;
foreach ($files as $file) {
$totalSize += filesize($file);
}
echo 'Total storage space used: ' . round($totalSize / 1024, 2) . ' KB';
?>