我正进入(状态:
我有以下功能:
public static function countDirectoryFiles($dir){
$i = 0;
if ( $handle = opendir($dir) )
{
while ( ($file = readdir($handle)) !== false )
{
if (!in_array($file, array('.', '..')) && !is_dir($dir.$file))
$i++;
}
}
// prints out how many were in the directory
return $i;
}
并且在opendir函数上发生错误,并说:
而D:\wamp\www\gillie\public/frontend/images/
albums/temp_storage_for_gallery/user_1/thumbnail/存在,我已经在Windows资源管理器中对其进行了多次检查。
我正在使用laravel 5.2,它使用Windows7与此错误无关。
由于过去3-4个月中相同的代码运行正常,我突然开始收到此错误。
我已经在互联网上搜索了此内容,但没有任何帮助。
更新
当我直接在下面的代码下运行时:
print(opendir('D:\wamp\www\abc\public\frontend\images\albums\temp_storage_for_gallery\user_1\thumbnail'));
我得到:
Resource id #469
任何指导将不胜感激!
最佳答案
经过一段时间的调试后,我知道我已经将存储在$ dir中的路径分解为no。的行以提高可读性并减少行的长度。由于这个原因,在该路径中错误地插入了空格,因此出现了问题。