Jump to content

[SOLVED] Referencing Windows Network Drive with PHP


mtorbin

Recommended Posts

Hey folks,

 

I'm primarily a Mac/Unix developer so working in the Windows world is a bit foreign to me.  I have a network drive that I want to connect located at:

 

\\myDrive\myDirectory\

 

When I type that into an address bar in Windows, I connect right away.  I can ping the drive with no problems.  However, when I type something like the following:

 

$dir1 = '\\\\myDrive\myDirectory\\';
opendir($dir1);

 

I get a "failed to open dir: Invalid argument in ...." error.  What am I missing?  I've tried researching this online but I haven't found anything that would suggest a solution.  Is this an IIS issue?  Is this a PHP issue?  Any help would be much appreciated.

 

Thanks,

 

- MT

 

Link to comment
Share on other sites

you are probably running PHP as an Apache service, which means the script is running as a SYSTEM account with no network privileges

 

Thanks for the quick response.  Where would I look to correct this issue?  The script ultimately needs to run as a "cron job" (not sure if the Windows term is the same) from the server where it currently resides.

 

- MT

Link to comment
Share on other sites

while you are testing, use PHP from the command line:

php -f /path/to/script.php

 

should work fine that way

 

Cool, I just tried that it it works.  However, if I'm running it from a terminal (i.e. command window) via RDP, then I'm running it under my account (not the SYSTEM account) which has privileges and thus it works, right?  I've already tested it on a local server and I know it works.  My only concern at this point is making the connection between the live server and the script server.

 

- MT

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.