1

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?
    – Dale
    Commented 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.
    – imvanzen
    Commented Sep 2, 2013 at 7:21

2 Answers 2

1

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

3
  • 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?
    – imvanzen
    Commented Sep 2, 2013 at 7:55
  • Yes, it supports SFTP, I used exactly this recently.
    – Vlad Preda
    Commented Sep 2, 2013 at 8:04
  • 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 :)
    – imvanzen
    Commented Sep 2, 2013 at 8:48
0

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

1
  • They are on the same server, but on different accounts. Fo log in to both i must use different credentials.
    – imvanzen
    Commented Sep 2, 2013 at 7:24

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.