我想读取某个目录的所有内容。我有下面的函数循环遍历目录并排列所有内容。唯一的问题是,我一直在为每个文件和目录获取filemtime(): stat failed
和filesize(): stat failed
。我试图寻找解决方案,但没有发现我的工作。我认为这可能是一个权限问题,但我可以从我正在安排的目录读写,所以这不是问题。有谁知道我该如何解决这个问题?filemtime()和文件大小()PHP错误
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]);
}
}
你给函数* full *路径和文件名吗? –