Hi, how would you open a folder, then get the filesize for each file, add them together and then display the total file size??
any ideas??
Regards,
Martin
Gaming Help And Info:
any ideas??
Regards,
Martin
Gaming Help And Info:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
$total = filesize($the_variable_that_contains_file);
<?php
$dir = "./";
echo "<table width=\"100%\">
<tr><td>Filename</td><td>FileSize</td><td>Filetype</td></tr>
<tr><td colspan=\"3\"><hr /></td></tr>
";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$fsize = filesize($dir . $file); // get filesize
echo "<tr><td>{$file}</td><td>{$fsize}</td><td>" . filetype($dir . $file) . "</td></tr>\n";
$numfiles++;
$sum_kb += $fsize;
clearstatcache(); // clear cache about files..
}
closedir($dh);
echo "<tr><td colspan=\"3\"><hr />Total filesize: {$sum_kb}<br />Number of files: {$numfiles}</td></tr>
</table>";
}
}
?>