apachenetwork-programmingservicenetwork-drivelinksys

accessing network drive with php open dir


I have a flash drive(or hdd) connected to Linksys Router and set it up for access without login. Then I setup netword drive at Computer(Windows 7 Proffesional x64). I tried opendir(\192.168.1.1); but i'm getting this error

 Warning: opendir(\\192.168.1.1\s2,\\192.168.1.1\s2): The network name cannot be found.       (code: 67) in C:\xampp\htdocs\movies.php on line 4
 Warning: opendir(\\192.168.1.1\s2): failed to open dir: No such file or directory in C:\xampp\htdocs\movies.php on line 4
 Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\movies.php on line 5

Then I tried couple of tips at php.net opendir comments, but when i tried to log on apache as my account I'm geeting error :

Windows could not start the apache2.4 service on Local Computer Error 1069: The service did not start due to a logon failure.

The PHP Code:

$path = '\\192.168.1.1\\s2';
$dir = opendir($path);
while($temp = readdir($dir))echo $temp;

EDIT : well i made apache to log on an admistrator account that i created specialy for this purpose, but still i'm getting this error:

Warning: opendir(\\192.168.1.1\s2\,\\192.168.1.1\s2\): The network name cannot be found. (code: 67) in C:\xampp\htdocs\movies.php on line 4

Solution

  • \192.168.1.1 is invalid address for network share. Have you tried \\192.168.1.1?

    And in both cases you should escape that \ and write the address as a proper string with quotation marks.

    Also, \\192.168.1.1 alone is not "a valid folder", you have to specify one of the network shares under this IP address.

    That being said, you should use opendir("\\\\192.168.1.1\\share").