我正在尝试读取某个目录的所有内容。下面有一个函数,它循环遍历目录并排列所有内容。唯一的问题是,我一直为每个文件和目录获取filemtime(): stat failed和filesize(): stat failed。我试着找出解决办法,但我发现的都没有用。我认为这可能是一个权限问题,但我能够从我正在安排的目录中读写,所以这不是问题所在。有人知道我怎么解决这个问题吗?
public function arrangeContents()
{
$currDir = opendir($this->path);
while($entryName = readdir($currDir))
{
$this->content[] = $entryName;
}
closedir($currDir);
$this->content_count = count($this->content);
for($i = 0; $i < $this->getContentCount(); $i++)
{
$this->names[] = $this->content[$i];
$this->name_hrefs[] = $this->content[$i];
$this->extns[] = $this->findExts($this->content[$i]);
$this->file_sizes[] = number_format(filesize($this->content[$i]));
$this->mod_times[] = date("M j Y g:i A", filemtime($this->content[$i]));
$this->time_keys[] = date("YmdHis", filemtime($this->content[$i]));
$this->sortContents($this->content[$i]);
}
}发布于 2014-03-31 04:04:25
我修复了这个问题,因为我没有将路径放在文件前面。
如果我只是将$this->dir . '/' . $this->content[i]放在每个函数中,它就能正确地给出一切。
发布于 2014-03-31 04:04:20
您弄错了文件路径,或者您没有权限对相关文件进行统计。
https://stackoverflow.com/questions/22753320
复制相似问题