File listing shows attributes in some folders but not in others
I'm having trouble trying to get attributes from files in my list. The code is:
if ($this->dir = opendir($caminho))
{
$this->itens = array();
$this->itensTotal = 0;
$tipos = array("dir" => 0, "file" => 1);
while ($item = readdir($this->dir))
{
if (!in_array($item, $this->skip))
{
$t = filetype($item);
$this->itens[$tipos[$t] . $item] = array("nome" => $item,
"size" => filesize($item),
"tipo" => $t,
"perm" => fileperms($item));
$this->itensTotal++;
}
}
}
Seeing that my script is 'file.php' and is in the folder 'www'. When it reads it's own folder (www) it works ok and lists all files and directoryies with their attributes. But when it tryies to read eg.: /www/folder/ the function filetype()
, filesize()
an fileperms()
doesn't works!开发者_如何学JAVA I get these warnings for all itens in the directory:
Warning: filetype() [function.filetype]: Lstat failed for bkp in D:\UniformServer\UniServer\www\files.php on line 174
Warning: filesize() [function.filesize]: stat failed for bkp in D:\UniformServer\UniServer\www\files.php on line 176
Warning: fileperms() [function.fileperms]: stat failed for bkp in D:\UniformServer\UniServer\www\files.php on line 178
It's opens the folder, read it's contents but these functions doesn't woks =s
Notes:
- As you can see I'm running it on Windows
$caminho
has valids paths
Please, any help will be welcome cause google doesn't helped.
The file operations use the real directory names on the system, not the relative path of the website, and "/www/folder"
probably doesn't exist then. From your comment, you would need either: "D:/UniformServer/UniServer/www/folder"
or use a relative path from the php script.
I think $item
only contain the basename of the file. You should probably prepend the directory path to it, like this: filetype(this->dir . $item)
.
精彩评论