I have two different services, websites on two different hosts, and there's one shared thing - Upload directory. Do you have some idea, how to solve that problem ? Or just how to share one admin Panel between two different websites, on two different hosts ?
2
-
So just for clarification, there's one upload script that needs to upload to two separate servers?– DaleCommented Sep 2, 2013 at 7:13
-
Not exacly.. there is two websites, two upload scripts on two hosts and i need to put uploaded files into one, shared folder. Which will be avaliable for those two servers.– imvanzenCommented Sep 2, 2013 at 7:21
Add a comment
|
2 Answers
I recommend you set up an FTP server, then upload the files to that FTP.
I normally use phpseclib library when working with FTPs (this library supports SFTP)
You will have access to all the files on the FTP from any of the servers.
Sample usage:
$sftp = new Net_SFTP('www.domain.tld');
$sftp->login('username', 'password');
$sftp->chdir('upload');
$sftp->put('filename.remote', 'xxx'); // string to be uploaded or file_get_contents('local.file')
$sftp->put('filename.remote', 'local.file', NET_SFTP_LOCAL_FILE);
$remoteFileContent = $sftp->get('filename.remote');
$sftp->get('filename.remote', 'local.file'); // copy remote file
$sftp->delete('filename.remote'); // delete file
PS: Removed error handling and includes for ease of reading
-
It's very got solution, but sorry, i forgot about one important thing. Server use SFTP protocol to transfer data. Whether the library supports SFTP?– imvanzenCommented Sep 2, 2013 at 7:55
-
-
I can't test it now because im doing other things but ill check it tomorrow and give you feedback. BTW, it looks good :) Thanks for now :)– imvanzenCommented Sep 2, 2013 at 8:48
If they are on the same server, have both websites write to the same directory (will need to give them both permission to do so).
-
They are on the same server, but on different accounts. Fo log in to both i must use different credentials.– imvanzenCommented Sep 2, 2013 at 7:24