I have stuck with this problem from the morning, I want to scan a directory on another server
\\\\TARIK3\Paretanires\SGM\recv
but I have this problem :
Warning: scandir(\TARIK3\Partenaires\SGM\recv,\TARIK3\Partenaires\SGM\recv): in C:\wamp\www\TRAITMENT DONEES\index.php on line 7
The code is :
$dir = "\\\\TARIK3\Partenaires\SGM\\recv";
$folder = scandir($dir);
$Fichier = fopen($folder[2], 'r');
What causes the problem in windows:
Apparently the problem is that apache uses an anonymous/local account and needs a "network/domain account"
How to Solve:
- Open "Start Menu" -> Run (or WindowKey+R) and typing
Services.msc
and pressing
enter.
- Find the Apache service. Having never used WAMP, I have no idea what it's been named. Hopefully it starts with the word "Apache" (or wampapache) though, and thus shouldn't be too hard to find.
- Right-click on the service and select Properties.
- Switch to the Log On tab.
- Select the radio button next to "This account:" and enter in the credentials for the user account you want to run Apache under. If it's a network/domain account, use the
DOMAIN\user
syntax (or search for the account using the Browse button)
- Select OK and restart the Apache service.
- Verify that your changes worked by looking for the "httpd.exe" process in Task Manager and checking to see which user name the process is running under.
And try:
$dir = '\\\\TARIK3\\Partenaires\\SGM\\recv\\';
or mapped:
$dir = 'Z:\\Partenaires\\SGM\\recv';
or:
$dir = 'Z:\\recv';
(Depends on how you mapped drives)
To add a service account to the local administrators group
- In Administrative Tools, click Computer Management.
- In the console tree, expand Local Users and Groups, and then click Groups.
- Right-click the Administrators group, and then click Add to Group.
- Click Add.
- Click Look in to display a list of domains from which users and groups can be added to the group.
- In Location, click the domain containing the users and computers you want to add, and then click OK.
- In Enter the object names to select, type the name of the user or group you want to add to the group, and then click OK.
- If you want to validate the user or group names that you are adding, click Check Names.
sources:
http://technet.microsoft.com/en-us/library/cc737693%28v=ws.10%29.aspx
http://de.php.net/manual/en/function.opendir.php#79685
http://board.phpbuilder.com/showthread.php?10371870-RESOLVED-Connection-to-a-network-Drive-Using-PHP/page2
https://stackoverflow.com/a/11186808/1518921