在php中替代ftp

so I'm writing a script, that will fwrite() a file. This file then needs to be sent to another server. I thought I would use the ftp wrapper, to open the file directly on the remote host.

Here's the problem. My webhost only allows url_fopen on port 80, and they don't allow any of the ftp_ functions.

So my question is: What would I do to transfer this document to another server? I might or might not be allowed to make some sort of script on the server that is to receive the file, but I doubt I could do anything useful.

The correct answers have already been said.

1) Find a decent host
2) Write a script to accept it on the remote server.
3) Write a script on a server then use that to bounce it to the server where it needs to end up.

If you have php and access through port 80 at least you still have options. But it all depends on the other server. You could for example do a normal file upload from your first server: http://us2.php.net/manual/en/function.http-post-fields.php

Skipping every notes on how much your hosting sucks, there are few alternatives how to do this:

  • On remote server run ftp server in passive mode on port 80 (desperate situation requires desperate measures), but since you're unable to use any ftp commands, you'd have to implement ftp from scratch or use full php implementation (not the best way to go).
  • Use SOAP
  • Build POST request and simulate uploading file (my personal favourite)

If you'll use second or third (I recommend 3rd), don't forget to implement authentication.