Thursday, August 11, 2011

PHP - access to remote folder


When I run my php code test_remote.php
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$dir = "\\\\10.29.227.65\\uploads";
$dh = opendir($dir);
$i = 0;
while (false!== ($filename = readdir($dh)))
{
print $filename."<br />";

if($filename<>"." and $filename<>"..")
{
$array[$i] = $filename;
$i++;
}
}
?>
I got the following error
Warning: opendir(
\\10.29.227.65\uploads) [function.opendir]: failed to open dir: No error in C:\gnsh\test_remote.php on line 8.

Firstly, I check  the folder \\
10.29.227.65\uploads can be accessed by my account (administrator).
 

I realize that the APACHE service must be set-up for my account (administrator). If no user is specified, APACHE uses an anonymous user and this is where the problem/error message is coming from. Go in control panel->administrative tools->services.  Right click on that and pop up the properties screen. In the tab LOG ON, not select local system account, but select this account and put my account name (administrator) and password. Restart Apache.

No comments:

Post a Comment