开发者

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


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.


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜