【问题标题】:The filename, directory name, or volume label syntax is incorrect. (code: 123)文件名、目录名或卷标语法不正确。 (代码:123)
【发布时间】:2017-05-27 12:20:48
【问题描述】:

我得到:

文件名、目录名或卷标语法不正确。 (代码: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/ 相册/temp_storage_for_gallery/user_1/thumbnail/,D:\wamp\www\abc\public/frontend/images/ 相册/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

任何指导将不胜感激!

【问题讨论】:

    标签: php windows opendir


    【解决方案1】:

    经过一段时间的调试,我知道我已经将存储在 $dir 中的路径分解为 no。行数以提高可读性和减少行长。由于这个路径错误地插入了一个空格,因此出现了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-17
      • 2020-06-07
      • 2020-04-08
      • 1970-01-01
      • 1970-01-01
      • 2021-01-07
      • 2019-04-29
      相关资源
      最近更新 更多