Re: ftp conection..
| From: | Chris Adams | Date: | Mon, 31 Jul 2000 19:29:25 +0000 |
| Subject: | Re: ftp conection.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9248@lists.php.net to get a copy of this message | ||
> I am creating a script which conects to a ftp server and downloads several
> files via fsockopen.
> So far, I have managed to log in, change directories and change type.
> But whenever I try to throw a "list" comand or use "retr filename" I get
> 425 Can't build data connection: Connection refused.
> I belive that I have to throw a PORT comand but I am not sure how to use
it.
Is there any reason why you can't just use the ftp:// URL syntax and the
normal file I/O functions? That'd be by far the easiest approach; another
thing to try would be the FTP extension in PHP4.
Otherwise, you'll need to read the FTP RFC to get all of the gory the
details on how FTP works; a separate data connection is used to transfer
directory listings & files, so you'll probably need to use PASV, which
allows you to open the data connection, instead of figuring out how to
handle the default FTP behaviour, where the server opens the connection back
to you (which would be messy to do in PHP).