Hey

i Have this script, that will list all files in a directory, and output them to screen.

i tried to add so the filesize would also show, it works fine if

$dir = ".";

But if i set $dir too etc. c:/apache/www
I get this error

Warning: filesize(): Stat failed for 01_Wildest_Dreams.mp3 (errno=2 - No such file or directory) in C:\apache\www\index.php on line 6
01_Wildest_Dreams.mp3 0 MB

my script looks like this:

<?php
$dir = "C:/apache/www";
if ($handle = opendir( $dir )) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != ".." && !strstr($file, '.php') && !strstr($file, '.html') && !strstr($file, '.txt') && !strstr($file, '.htaccess')) {
                $fl_size = filesize($file) / 1048576;
                $size = round($fl_size, 2);
            echo "<a href=download.php?$file>$file</a> $size MB<br>\n";
        }
    }
    closedir($handle);
}
?>

hope some one can help me with this

    you need to supply [man]filesize[/man] with the full path to file, not just a filename.

      Ahh ofcourse
      Works now, thanks for helping 🙂

        Write a Reply...