Code: Select all
<?php
function format_size($file) {
$sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
if ($file == 0) { return('n/a'); } else {
return (round($file/pow(1024, ($i = floor(log($file, 1024)))), 2) . $sizes[$i]); }
}
$current_dir = "/export/home/ftp"; //Put in second part, the directory - without a leading slash but with a trailing slash!
$dir = opendir($current_dir); // Open the sucker
echo ("<p><h2>Workstation Software Updates</h2></p><br />");
while ($file = readdir($dir)) // while loop
{
$parts = explode(".", $file); // pull apart the name and dissect by period
if (is_array($parts) && count($parts) > 1) { // does the dissected array have more than one part
$extension = end($parts); // set to we can see last file extension
if ($extension == "zip" OR $extension == "ZIP") // is extension ext or EXT ?
echo "<li><a href=\"$file\" target=\"_blank\">$file - format_size()</a></li><br />"; // If so, echo it out else do nothing cos it's not what we want
echo "format_size()";
}
}
echo "<br />";
?>