php between 2 networked computers

andreas_d

Registered
i'm not even sure if this is possible but i'll ask anyway. I need to set up a network between two computers that have php enabled on both, and then have a php script on one computer that fopen() s and fwrite()s into a .txt file on the other. This is as far as i have gotten.
So far i have been testing with just one computer (i have to do the final networking between 2 comps at college) I've enabled file sharing and enabled php on the computer. So far so good. PHP is working just fine. The script is extremely simple. At the moment both the php script and the .txt file are in the Sites folder. As a result all i need to do to target the .txt file is refer to it by name. for example

$textvar = "mytext.txt";
$file = fopen( $textvar, "w");

The next step i was taking was trying to target it by giving the absolute path to the .txt file. My rational was that if i could do that, then it might not be difficult to target the text file on the other computer by giving an absolute path to it there(am i right in thinking this?).
The address that i use to navigate to the php file through the browser is
'http://myHD.local/~adelos/info/altertext.php'
to view the text file its
'http://myHD.local/~adelos/info/mytext.txt'

i tried changing the php script to:
$textvar = 'http://myHD.local/~adelos/info/mytext.txt' ;
$file = fopen( $textvar, "w");

but it no longer works
what is strange is that the above absolute path works in html documents for example embeding a swf file:
<embed name ="sunset" src ="http://myHD.local/~adelos/info/myswf.swf" height = 550 width = 450></embed>

as well as accesing a php script through Flash:
this.info.load ("http://andreas.local/~andreasdilaveris/info/getvars.php");

That's as far as i have gotten. I hope that all made sense. If anyone can help me figure out how to accomplish what i want to do i would be really greatfull. Thanks in advance
 
Wouldn't you have to refer the files by an absolute FILESYSTEM name if you want to use them like this? That is, you'd have to mount the remote filesystem by some means (cifs/smb, nfs, etc) and then access the file at "/Volumes/fs01/Users/andreas..."?
 
You can also do this over HTTP if you have writetofile.php scripts on the remote site.

(Beware security issues if these machines are also connected to the Internet.)

You can make NFS mounts between the two machines, or simply mount the remote drives via file sharing. That way you be able to write directly to the remote drive. With file sharing you'll need to keep a priveledged user logged in.
 
Back
Top