Solved

Using the directoryIterator class to read remote directory

Posted on 2008-10-13
4
704 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
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:AlexanderR
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now