Accessing files on the LAN

I have a bit of code that looks like

define("DIRECTORYPENDING","import/pending");

$d = dir(DIRECTORYPENDING);
while (false !== ($file = $d->read()))
{
// Process all files in that directory
}


Which works fine for directories within the website.

In this particular case, however, the files I need are on a shared directory
on another server on the LAN (all servers are Server2003) at
\\server2\pending (or a mapped drive, Z:, pointing to the same location)

I've tried

define("DIRECTORYPENDING",\\server2\pending);
define("DIRECTORYPENDING","Z:\pending");

but it doesn't work (yes, I do have quotes in the correct place on the
define statements above, but Outlook Express removed them!)

The error message I get is

Warning: dir(\\server2\pending\) [function.dir]: failed to open dir:
Invalid argument in E:\TestOnline\lit\admin.php on line 58

Where the line in error is the line containing $d = dir(DIRECTORYPENDING)


So... how can I read the files from the remote directory? I have control of
both servers, so can change permissions etc if required.


TIA,

Pete.
PeteC [ Mi, 16 Mai 2007 09:50 ] [ ID #1714998 ]

Re: Accessing files on the LAN

On May 16, 8:50 am, "PeteC"
<newsgroupswebdev... [at] removethisbitacutecomputing.co.uk> wrote:
> I have a bit of code that looks like
>
> define("DIRECTORYPENDING","import/pending");
>
> $d = dir(DIRECTORYPENDING);
> while (false !== ($file = $d->read()))
> {
> // Process all files in that directory
> }
>
> Which works fine for directories within the website.
>
> In this particular case, however, the files I need are on a shared directory
> on another server on the LAN (all servers are Server2003) at
> \\server2\pending (or a mapped drive, Z:, pointing to the same location)
>
> I've tried
>
> define("DIRECTORYPENDING",\\server2\pending);
> define("DIRECTORYPENDING","Z:\pending");
>
> but it doesn't work (yes, I do have quotes in the correct place on the
> define statements above, but Outlook Express removed them!)
>
> The error message I get is
>
> Warning: dir(\\server2\pending\) [function.dir]: failed to open dir:
> Invalid argument in E:\TestOnline\lit\admin.php on line 58
>
> Where the line in error is the line containing $d = dir(DIRECTORYPENDING)
>
> So... how can I read the files from the remote directory? I have control of
> both servers, so can change permissions etc if required.
>
> TIA,
>
> Pete.

firstly use a decent newsreader that is capable of posting the actual
code to the group.
secondly backslashes are meaningful, so use \\\\server\\share
thirdly permissions must indeed be set correctly, access to share must
be granted to process under which php is running.
shimmyshack [ Do, 17 Mai 2007 15:46 ] [ ID #1715006 ]
PHP » alt.php » Accessing files on the LAN

Vorheriges Thema: phpMini -- Developers Release
Nächstes Thema: virus sent vie webmail running on Apache