来自filetype,filesize和filetime的警告

To be quick, I am building a file browser for an application I am using. I am getting the following error when I request the filetype, filesize and filetime. I get the following errors:

Filetype:

Warning: filetype() [function.filetype]: Lstat failed

filesize:

Warning: filesize() [function.filesize]: stat failed

filetime: Shows me that the files were modified 01/01/1970 at 03:00:00 AM. I was surely not editing those files then!

Regardless, here's my code. I apologize for the spaghetti of echos! Please help!

<table class="tftable">
<tr><th>Name</th><th>Type</th><th>Last Modified</th><th>Size</th></tr>

<?php
if($_GET['folder'] == "")
{
$baseusrdir = "/userfiles/john";
}
else
{
$baseusrdir = "/userfiles/john/".$_GET['folder'];
}

$listdir = scandir(".".$baseusrdir);
$lstdr = $_GET['folder'];

foreach($listdir as $lstdr)
{   
    if($lstdr != "." && $lstdr !="..")
    {
    echo "<tr>";
    echo "<td><a href='files.php?folder=".$_GET['folder']."/$lstdr'>".$lstdr."</a></td>";
    echo "<td>";
    echo $baseusrdir."/".$lstdr;
    echo filetype($baseusrdir."/".$lstdr);
    echo "</td><td>";
    echo date ("d/m/Y h:i:s A.", filemtime($entry));
    echo "</td><td>";
    echo round((filesize($lstdr)/1000), 2);
    echo "</td>";
    echo "</tr>";
    }
}
$arr = explode('/' , $_GET['folder']);
for($i=0;$i<(count($arr)-1);$i++){
    if(!empty($arr[$i])){
        $link.="/".$arr[$i];
    }

}
echo "</br><a href='files.php?folder=$link'>back</a>";
?>
</table>

Abhi Jain - quote:

The most common cause of filetype() raising this warning and not showing a filetype() in the output (it actually returns NULL) is, if you happened to pass just the 'Dir or File Name' and not the complete "Absolute or Relative Path" to that 'file or Dir'. It may still read that file and return its filetype as "file" but for Dir's it shows warning and outputs NULL. eg: $pathToFile = '/var/www'; $file = 'test.php'; $dir = 'somedir';

http://php.net/manual/en/function.filetype.php - see coments

To get the file type, I use this function:

function getFileType($file){
    $path_chunks = explode("/", $file);
    $thefile = $path_chunks[count($path_chunks) - 1];
    $dotpos = strrpos($thefile, ".");
    return strtolower(substr($thefile, $dotpos + 1));
}