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/s ites/domai nname.com/ public_htm l/images/e tc') as $file)
{
if (!$file->isDot())
{
print $file->getFilename();
}
}
I get errors. Is it not possible to do this?
Any help much appreciated!
Daisy
I am using the class to get a list of file names on my localhost like this:
foreach ( new DirectoryIterator('c:/wamp
{
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/s
{
if (!$file->isDot())
{
print $file->getFilename();
}
}
I get errors. Is it not possible to do this?
Any help much appreciated!
Daisy
Perhaps its a security restriction on the server. Do you HAVE to use full path? Can your class just accept "images/etc"?
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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