Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 830
  • Last Modified:

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
0
daisydoos
Asked:
daisydoos
  • 2
  • 2
1 Solution
 
AlexanderRCommented:
Perhaps its a security restriction on the server.  Do you HAVE to use full path?  Can your class just accept "images/etc"?
0
 
daisydoosAuthor Commented:
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
0
 
AlexanderRCommented:
Oh, sorry.
I thought both the images and the script gets uploaded.  So the script remains on your local computer but has to scan remote ftp site.  Am i correct this time?

What kind of errors do you get.  Do you use ftp specific functions , like ftp_nlist http://bs.php.net/manual/en/function.ftp-nlist.php.  You probably should post your DirectoryIterator for us to see.
0
 
daisydoosAuthor Commented:
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
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now