Problems with fopen FTP upload to another server

[email protected] ("John P. Mulligan")
Newsgroups php.general
Message-ID <[email protected]>
The Project:
I am working on a project that requires that I move a file from the local
server to an arbitrary remote server (given a username and password) via
FTP using PHP.  The project is a content management system of sorts, and I
will need to be able to allow users to press a "Publish" button and it will
FTP a local HTML file to their remote webserver of choice.

The Problem:
The documentation pointed me to using fopen().  But the following command
fails with an "Transport endpoint not connected" error when I try to use it:

$fp = fopen("ftp://user:[email protected]/file.txt","w");

When followed by a fputs(), that command should open a passive FTP session
with hostname.com and allow me to write to file.txt (which may or may not
exist on the remote server).  But it fails every time.

I thought about using fsockopen() and writing my own FTP connection
functions, but it is way too difficult (FTP uses two ports 21/20 and such),
and would be basically reinventing the wheel.

Due to project constraints and such, assume that I can not use the PHP4
ftp_ functions, and that I cant recompile PHP with the ftp_ functions.
Also, I must use FTP to transfer the files, not any other protocol.  And
assume that I can not use any third party stuff, such as ncFTP or Perl.  It
all has to be PHP3.

I have tried connecting to many servers, all of which support boh active
and passive FTP sessions without a problem.  So the problem is defninitely
in the PHP, not the servers.

Any help would be greatly appreciated.  

Please cc: my email address with your replies, as I am not subscribed to
this mailing list.

Thank you in advance,
John



John P. Mulligan <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.