[SOLVED] accessing files across local servers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skylark
Forum Newbie
Posts: 3
Joined: Wed Jun 23, 2004 3:35 pm

[SOLVED] accessing files across local servers

Post by skylark »

where "theserver" is a machine other than the one running PHP (under an apache install on a windows box), but accessible through the local network (it is visible, for instance, under the "microsoft windows network" in explorer), an image link of the form:

Code: Select all

<img src = "\\theserver/adirectory/imagefile.jpg">


properly loads the image into the browser.

and yet i can get no command to actually access that file and manipulate it. for instance,

Code: Select all

<?php
$fs = fopen("\\\theserver/adirectory/imagefile.jpg","r"); 
?>
returns either an invalid argument error or the error:

Code: Select all

php_network_getaddresses: gethostbyname


oddly enough, which error comes back seems not to be entirely consistent.

any thoughts?
Last edited by skylark on Fri Jun 25, 2004 3:39 pm, edited 1 time in total.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Have you tried....

Code: Select all

<?php
$fs = fopen("//theserver/adirectory/imagefile.jpg","r");
?>
You could also try specifying the remote machine by IP.
skylark
Forum Newbie
Posts: 3
Joined: Wed Jun 23, 2004 3:35 pm

Post by skylark »

i have tried both of those options, and neither works.
skylark
Forum Newbie
Posts: 3
Joined: Wed Jun 23, 2004 3:35 pm

Post by skylark »

Code: Select all

<?php
$fs = fopen("\\\\server\\directory\\file.ext","rb");
?>
i got this to work. everything had to be backslashes for the path to read correctly, and it takes *4* backslashes to render a correct doubleslash. i could swear i'd tried this before, but it seems to work now. i have reason to believe that actually logging in to the machine and getting it to see the other server's path through the windows network may have broken the logjam.
Post Reply