3

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.

Vyktor
  • 20,559
  • 6
  • 64
  • 96
Dumle29
  • 809
  • 1
  • 6
  • 13
  • another server will accept ?? – Arun Killu Oct 24 '12 at 06:41
  • Are both servers with the same host? Do you have any kind of shell access? – Joshua Kaiser Oct 24 '12 at 06:43
  • AFAIK there's not a lot of alternative.. Maybe you should try to send the file via `POST` to the server, if you get a chance to write a small script on the distant server. – Touki Oct 24 '12 at 06:44
  • 1
    Port 80 is HTTP. If the other server supports it, you can make use of HTTP PUT method or WEBDAV. – hakre Oct 24 '12 at 06:44
  • @ThiefMaster I would prefer to ask rather than just assume. If you can use shell access you might be able to use exec() and run scp to transfer the file via ssh. Otherwise, I agree with hakre. HTTP PUT or Webdav seem reasonable. It's really hard to say without knowing specifics about your hosting environment. – Joshua Kaiser Oct 24 '12 at 06:49

3 Answers3

1

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.

Community
  • 1
  • 1
Vyktor
  • 20,559
  • 6
  • 64
  • 96
0

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.

William
  • 471
  • 3
  • 14
  • I'm sorry, but "find a decent host" is not an alternative to FTP. – Joshua Kaiser Oct 24 '12 at 06:52
  • I listed 3 good answers. You choose to focus on one for some reason and yes finding a new host is an option for the OP.If the PHP configuration is so castrated that it doesn't allow PHP then I would probably guess correctly when I say other things he'll need in the future are disabled as well. – William Oct 24 '12 at 06:59
  • Yes, i have had to deal with other limitations before. Untill now, unlimited subdomains, with custom dns and 24/7 livechat made up for it. But now i've ordered a new domain. 0.2 usd for the first year, due to celebration of new servers is a sweat deal :P – Dumle29 Oct 24 '12 at 07:37
  • You could build your own host with Filezilla FTP server (Free). – Erik Schroder Mar 20 '20 at 12:55
0

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

NilsB
  • 1,154
  • 1
  • 16
  • 42