php opendir not working

I want to scan for all folders and files within folder c:/data
But i am getting below error.
Warning: opendir(c:/data,c:/data): The system cannot find the file specified. (code: 2)
	function listFolderFiless($dir){
    $ffs = scandir($dir);
    $i = 0;
    $list = array();
    foreach ( $ffs as $ff ){
        if ( $ff != '.' && $ff != '..' ){
            if ( strlen($ff)>=5 ) {
                if ( substr($ff, -4) == '.php' ) {
                    $list[] = $ff;
                    //echo dirname($ff) . $ff . "<br/>";
                    echo $dir.'/'.$ff.'<br/>';
                }    
            }       
            if( is_dir($dir.'/'.$ff) ) 
                    $this->listFolderFiless($dir.'/'.$ff);
        }
    }
    return $list;
}

Open in new window

But  result is same
LVL 15
InsoftserviceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ahmed MerghaniSoftware EngineerCommented:
I think your path should be c:\data
0
InsoftserviceAuthor Commented:
Tried even that
str_replace("/","\\","c:/data");
even tried giving hard code value.

This code worked on my local server but not on windows 2003 server

function ListIn($dir, $prefix = '') {
            
              $dir = rtrim($dir, '\\/');
              $result = array();

                  $h = opendir($dir);
                  
                  while (($f = readdir($h)) !== false) {
                    if ($f !== '.' and $f !== '..') {
                        if (is_dir("$dir/$f")) {
                          $result = array_merge($result, $this->ListIn("$dir/$f", "$prefix$f/"));
                        } else {
                          $result[] = $prefix.$f;
                        }
                    }
                  }
                  closedir($h);

              return $result;
            }
0
Dave BaldwinFixer of ProblemsCommented:
This works fine for me.
$handle = opendir('C:\\Food')

Open in new window

0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Ahmed MerghaniSoftware EngineerCommented:
Ok. I tested the code and it runs successfully either c:/data or c:\data - and some times it need to be c:\\data-. What is your PHP version? what OS you are using? Are you sure the folder "data" is existed?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
InsoftserviceAuthor Commented:
windows 2003 server . php5.4
0
InsoftserviceAuthor Commented:
Client had given permission to the folder on the server.
Its  resolved thx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.