assaqqaf
assaqqaf

Reputation: 1585

how to save uploaded file in another server?

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??

Upvotes: 0

Views: 2661

Answers (4)

Stewie
Stewie

Reputation: 3131

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.

Upvotes: 3

Shikiryu
Shikiryu

Reputation: 10219

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...

Upvotes: 0

Otar
Otar

Reputation: 2591

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

Upvotes: 1

MK.
MK.

Reputation: 34587

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.

Upvotes: 0

Related Questions