Page 1 of 1

Reading Files On A Remote Server

Posted: Sun Nov 11, 2007 7:46 pm
by mozartmatt
Hi,

I've been having a go at creating some kind of automated synchronization between my home computer and work computer using PHP. What I would like to do is the following:

1. Read files in C:/sync/ folder on local computer (done!)
2. Read files on remote server
3. Compare Data (last modified, last accessed etc..)
4. Update local computer with files on the remote server and vice versa.

To add new files to the remote server I just want to throw another file in my C:/sync/ folder and the PHP script realises there is a new file there and creates a copy of it on the remote server. When I get to work, I just visit the webpage and it "synchronises" my work computer with my home one by downloading all the latest files, using the remote server as a gateway.

I'm having trouble with this whole remote server stuff. I can't get opendir(/files/) to work because it just leaves me with:
opendir(/files/): failed to open dir: not implemented in c:\intranet\sync\index.php on line 66
I understand why it isn't possible (using http://) to do it for obvious security reasons, but is there a way around it? I have access to the remote server - obviously - so is there some settings I need to change?! I appreciate that this could be an Apache question, I'm unsure what to do next!! lol Are there any better functions to achieve it in PHP?

Failing all this... is there a better way of doing it that automates uploading files from a computer to a remote server AUTOMATICALLY in PHP (not using some "original" upload script).

Thanks in advance,

Matt[/quote]

Posted: Sun Nov 11, 2007 8:46 pm
by feyd
PHP doesn't natively support a simple way to get a directory listing from a remote server. You will need to either build a library or use an existing one.

Honestly though, what you want is to use something like rsync or even a basic FTP program that supports synchronizing.