Always_a_learner
Always_a_learner

Reputation: 5055

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

I am getting:

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

I have below function:

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;
    }

and error occurs on opendir function and says:

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/)

whereas D:\wamp\www\gillie\public/frontend/images/ albums/temp_storage_for_gallery/user_1/thumbnail/ exist and I have checked it several times in my windows explorer.

I am using laravel 5.2 which has nothing to do with this error, using windows7.

I have started getting this error all of sudden as the same code was working fine from last 3-4 months.

I have searched about this on internet but nothing helped.

Update When I run directly below code:

print(opendir('D:\wamp\www\abc\public\frontend\images\albums\temp_storage_for_gallery\user_1\thumbnail')); 

I get:

Resource id #469

Any guidance would be appreciated!

Upvotes: 2

Views: 5103

Answers (1)

Always_a_learner
Always_a_learner

Reputation: 5055

After some more time of debugging I came to know that I have broken down path which was stored in $dir into no. of lines for improving readability and for decreasing length of lines. Due to this a space was inserted by mistake into this path, thus the problem occurred.

Upvotes: 1

Related Questions