for some reason if i change $handle in the below script from:

if ($handle = opendir('.')) {

to:

if ($handle = opendir('files')) {

it splurts out this error:

Warning: filesize() [function.filesize]: stat failed for ajaxpagefetcher.js in /home/.philadelphia/homer09001/files.dth-scripts.com/listfiles.php on line 11

Warning: filesize() [function.filesize]: stat failed for Anim8or.exe in /home/.philadelphia/homer09001/files.dth-scripts.com/listfiles.php on line 11

<table border="1"><tr><td>FileName</td><td>File Size</td><td>File Type</td></tr>
<?php

if ($handle = opendir('files')) {
    while (false !== ($filename = readdir($handle))) {
        if ($filename != "." && $filename != "..") {

if(is_dir($filename) == FALSE)
{

$filesize = filesize($filename);

if ($filesize < pow(2,10)){
	$totalsize = "$filesize B";
}
if ($filesize >= pow(2,10) && $filesize < pow(2,20)) {
	$totalsize = round($filesize / pow(2,10), 2)." KB";
}
if ($filesize >= pow(2,20) && $filesize < pow(2,30)) {
	$totalsize = round($filesize / pow(2,20), 2)." MB";
}
if ($filesize > pow(2,30)) {
	$totalsize = round($filesize / pow(2,30), 2)." GB";
}

$path_info = pathinfo($filename);
$ext = $path_info['extension'];


echo "<tr><td>$filename</td><td>$totalsize</td><td>$ext</td></tr>";
        }}
    }
    closedir($handle);
}
?>

    What platform are you working under?

    I remember reading once filesize can act strange on a mac if the folder doesn't have write permissions. I've not tested this theory however.

      im running it on my paid hosting server which is running linux, is there any other way round this problem then?

        Write a Reply...