m0biu5, I know nothing of PHP and have no idea how to implement what you are talking about. Maybe my younger brother can help me with that.
hazza96, your code woks nicely. Thanks.
I also found this code on the Internet somewhere. It displays the filesize as well as a thumbnail if desired. Just read the comments to see where to place the "#icon" tag to get a thumbnail. This is in http://www.pegasus.rutgers.edu/~pax/index.old2.php. Having the following code be able to alphabetize would be ideal. Otherwise I'll just keep using the second bit of code you posted. it worls well.
Code:
<html>
<body>
<?php
// handy humansize function:
// input is number of bytes, output is a "human-readable" filesize st\ring
function humansize($size) {
// Setup some common file size measurements.
$kb = 1024; // Kilobyte
$mb = 1024 * $kb; // Megabyte
$gb = 1024 * $mb; // Gigabyte
$tb = 1024 * $gb; // Terabyte
if($size < $kb) return $size."B";
else if($size < $mb) return round($size/$kb,0)."KB";
else if($size < $gb) return round($size/$mb,0)."MB";
else if($size < $tb) return round($size/$gb,0)."GB";
else return round($size/$tb,2)."TB";
}
// get local directory path
$path= dirname($_SERVER['SCRIPT_FILENAME']);
?>
<h3>Files in <?php print $path; ?>:</h3>
<ul>
<?php
$d = dir($path);
$icon = '';
while (false !== ($entry = $d->read())) {
if ( substr($entry, 0, 1)=='.' ) continue;
// get size
if ( substr($entry, 0, 1)=='.' ) continue;
// get size
$size = filesize($path.'/'.$entry);
$humansize = humansize($size);
// find filename extension
$dotpos = strrpos($entry, '.');
// creates the thumbnails
if ($dotpos) {
$ext = substr($entry, $dotpos+1);
if ($ext === 'jpeg' || $ext === 'gif' || $ext === 'pn\g') {
$icon = "<img src='$entry' style='width: 50p\x; height: auto; vertical-align: text-top;' alt='icon' title='$entry' />";
}
}
print "<li><a href='$entry'>$entry</a> ($humansize)</li>\n"; \//place "$icon" in the text to show a thumbnail.
$icon= '';
}
$d->close();
?>
</ul>
<hr width="100%">
Bookmarks