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! 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 174Warning: filesize() [function.filesize]: stat failed for bkp in
D:\UniformServer\UniServer\www\files.php on line 176Warning: 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
$caminhohas 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.