Solved

Using the directoryIterator class to read remote directory

Posted on 2008-10-13
4
790 Views
Last Modified: 2009-07-29
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
Comment
Question by:daisydoos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:AlexanderR
ID: 22704721
Perhaps its a security restriction on the server.  Do you HAVE to use full path?  Can your class just accept "images/etc"?
0
 

Author Comment

by:daisydoos
ID: 22705142
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
 
LVL 11

Accepted Solution

by:
AlexanderR earned 125 total points
ID: 22705218
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
 

Author Comment

by:daisydoos
ID: 22708906
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question