0
votes

I am attempting to read a open a directory using opendir(), and then loop through the files in that directory. The ultimate goal for this script is to transfer certain files from the directory that is being read to a different FTP server.

The "FTP" part is what's screwing me up—and I have no idea why!


On some servers (this script is expected to be run across several) I am receiving the following error:

Warning: opendir(ftp://[email protected]/streaming)
[function.opendir]: failed to open dir: FTP server reports 550
Can't find file in [PATH] on line 88

[PATH] would be the actual path to the PHP script, of course.


Line 88 is as follows:

if ($handle = opendir($from))

The variable $from represents a complete FTP path.


The complete FTP path is as follows:

 ftp://[USERNAME]:[PASSWORD]@[SERVER]/streaming

I have confirmed that directory is correct. When I copy and paste the directory into my web browser, for example, Firefox opens a directory tree containing all of the files, exactly as expected. In other words, though PHP is complaining that it "can't find file", the "file" (that is the directory, I believe) actually does exist.

What on earth is going on? As I mentioned before, this script does work on some servers. The thing holding it up appears to be whether or not the server is Windows-based, as it works fine on the Linux servers I have tested. Unfortunately, I do not have access to the servers, though our server administrator can make changes if we can isolate the problem.

Why am I receiving this error, and is there a workaround?

1
you should to look into ftp_connect if adding a trailing / doesn't help php.net/manual/en/function.ftp-connect.phpcmorrissey

1 Answers

0
votes

Add a trailing slash / see if that resolves the issue there was a bug in PHP which has been fixed.