Question

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');
Was it helpful?

Solution

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:

  1. Open "Start Menu" -> Run (or WindowKey+R) and typing Services.msc and pressing enter.
  2. 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.
  3. Right-click on the service and select Properties.
  4. Switch to the Log On tab.
  5. 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)
  6. Select OK and restart the Apache service.
  7. 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

  1. In Administrative Tools, click Computer Management.
  2. In the console tree, expand Local Users and Groups, and then click Groups.
  3. Right-click the Administrators group, and then click Add to Group.
  4. Click Add.
  5. Click Look in to display a list of domains from which users and groups can be added to the group.
  6. In Location, click the domain containing the users and computers you want to add, and then click OK.
  7. 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.
  8. 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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top