Copy Files from one server to another using PHP
I have hosted my web site on one server (server 1)and my media files are stored on other server (server 2). Now server 2 has sftp login system. Server2 is the media server.
When the user enter his username on my web page on server1 , I want to list all the files from server2 on to this web page. So how can I write a script that would allow me to login to server2 which has sftp and get the list of the files.
All files are stored in following format
GourpID - UserId -media<computer generated random number).flv
If we cannot do it with Php then what would be the best way to do it.
You could have a basic php script on Server 2 that accepts a secret key so it can list user's files.
let's say server2/sys/app/list-files.php?secret=abc12345&user_id=123
For additional security on Server 2 you might want to also check for the REMOTE_ADDR in list-files.php
Another option is to setup key based login and use ssh to list users files.
hope this gives you an idea how to proceed.
Maybe use PHP's FTP functions?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)