Access is denied. (code: 5) PHP

1

I'm using the code below to try to read the files in a directory.

$dir = "\\192.168.44.19\Controles\Inventario de Equipamentos\A\ " ;
$pasta= opendir($dir);


echo("<li data-role='list-divider'><a href='#'>B</a></li>"); 

while ($arquivo = readdir($pasta)){
  if ($arquivo != '.' && $arquivo != '..'){
     echo "<li><a href='".$dir.$arquivo."' rel='external' >".$arquivo."</a></li>";
  }
}

But I get the error message:

  

Access is denied. (code: 5) in C: \ wamp \ www \ terms \ index.php on line 30

    
asked by anonymous 28.09.2015 / 14:32

2 answers

1

Solution found

It is necessary to configure the service with some network user who has the directory access permission. I went to Start> Run> services.msc and found the wampapache service. Then I right-clicked the properties > login & entered the account data with access.

Resolved

    
01.10.2015 / 20:36
0

Lucas, this problem can be linked to several factors, internal to the language or even external to it, such as Firewall, Network, Folder Permissions and Users.

Firewall

The computer being accessed has a firewall or anti-virus that is not letting the host in.

Network

Is the network correctly shared in folders, network group, and etc?

Folder Permissions

Are folder permissions correct and share correctly on the network? permissions for specific users or groups?

In Windows, there is little management of permissions, outside Windows Server, which is the largest control. Take a look at this.

If the machine you are accessing is UNIX terminal you need to set read permissions for the folder:

chmod 0755 /path/folder/ -R

Well, it's not a code error, apparently, but it's host permissions. Take a look at these tips and tell me what you think.

    
28.09.2015 / 15:47