Link to home
Start Free TrialLog in
Avatar of daisydoos
daisydoos

asked on

Using the directoryIterator class to read remote directory

Hi,
I am using the class to get a list of file names on my localhost like this:

foreach ( new DirectoryIterator('c:/wamp/www/name/images/etc') as $file)
{
      if (!$file->isDot())
      {
            print $file->getFilename();
      }
}

All fine.

What I want to do is to read the same directory on a remote server - to make sure when I copied the files using FTP they were all done. However, when I try placing the path in the constructor like this:

foreach ( new DirectoryIterator('/home/sites/domainname.com/public_html/images/etc') as $file)
{
      if (!$file->isDot())
      {
            print $file->getFilename();
      }
}

I get errors. Is it not possible to do this?

Any help much appreciated!

Daisy
Avatar of AlexanderR
AlexanderR
Flag of Canada image

Perhaps its a security restriction on the server.  Do you HAVE to use full path?  Can your class just accept "images/etc"?
Avatar of daisydoos
daisydoos

ASKER

Hi Alexander,

Thanks for your response.

The thing is I want to compare the contents of the directory on localhost eg images/products and do the same on the remote server. If use images/products for the remote query, I am just pulling off the files on my local machine.

Any other thoughts on how I can do this?

Many thanks

Daisy
ASKER CERTIFIED SOLUTION
Avatar of AlexanderR
AlexanderR
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Alexander,

That's great - thanks! I am using this ftp_nlist in conjunction with the directoryIterator to compare the 2 directories - all is well - many thanks,

Daisy