0

I have tow servers for my web site. first, for database and php files. the second, for save useres' uploaded files.

So, if I uploade a file in server-1 xxx.com. how could i save it in server-2 yyy.com??

3
  • Use Curl/Filestreaming to move file1.txt with script1.php to script2.php
    – Julius F
    Commented Sep 29, 2010 at 14:22
  • More info please. What is server 2 running? What options do you have to receive a file on server 2? FTP? SSH? PHP? A network share?
    – Pekka
    Commented Sep 29, 2010 at 14:22
  • You might want to clearify the scenario. Is this about something like a distributed filesystem?
    – Gordon
    Commented Sep 29, 2010 at 14:23

4 Answers 4

3

if you want two servers to be exact clones (contianing same files) you can run a rsync script after your first uplaod has completed. Its very easy and best of you don't have to specify files.

Lets say you want to transfer all files in directory /files/ to server2 in directory /files/2/ You can run this :

rsync /files/ yyy.com:~/files/2/ 

If you ONLY want specific files (extensions) to be synced, you can do this:

rsync /files/*.mp3 yyy.com:~/files/2/ 

The above will move ONLY MP3.

0
1

You can simply upload one file from server 1 to the server 2 using PHP's FTP functions.

See code example here: http://www.jonasjohn.de/snippets/php/ftp-example.htm

0

Use shared storage (SAN). Or SMB shares if on Windows. Or NFS if on Unix. Or scp (ssh) with public key authentication if on Unix.

0

An ugly way I used once was to pass via cURL and FTP commands

Of you course, you need to have access to your server-2 FTP...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.