php - 文件名、目录名或卷标语法不正确。 (代码 : 123)

标签 php windows opendir

我得到:

The filename, directory name, or volume label syntax is incorrect. (code: 123)

我有以下功能:

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 函数发生错误并说:

opendir(D:\wamp\www\abc\public/frontend/images/ albums/temp_storage_for_gallery/user_1/thumbnail/,D:\wamp\www\abc\public/frontend/images/ albums/temp_storage_for_gallery/user_1/thumbnail/)

而 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。行以提高可读性和减少行的长度。因此在这个路径中误插入了一个空格,所以出现了这个问题。

关于php - 文件名、目录名或卷标语法不正确。 (代码 : 123),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41612400/

相关文章:

php - 在 Windows 上的远程服务器 (FTP) 上使用 Eclipse 开发 PHP

php 注释 - 最小的工作示例

javascript - Windows 小工具 - javascript 更改 CSS

perl - 无法打开目录,或者我的(Perl)代码有什么问题?

c - Linux, C : access() not catching permission problems, 之类的

php - 想要降级 phpMyAdmin,但不知道什么版本

php - Laravel 错误 : Call to a member function format() on string

windows - Windows 64 位上的 SWT

c++ - 内联方法时数组不会改变

关于 opendir 和 readdir 的 Perl 程序帮助