Fopen Permission denied

1

I try to read a TXT file on the network, but PHP always returns permission error. The folder is shared and I can see it through the windows network.

Server use Windows with IIS7 .

In% local% I can access these files via xampp normal.

ini_set('display_errors',1);
error_reporting(E_ALL);

$ponteiro = fopen ("//192.168.1.2\DADOSTXT\arquivo.TXT","r") or die("ERRO");

while(!feof($ponteiro)){
  $linha = fgets($ponteiro,4096);
  echo $linha."<br>";
}

fclose ($ponteiro);

Any help?

    
asked by anonymous 03.06.2015 / 12:58

1 answer

1

You have some details to fix:

  • Instead of //192.168.1.2\ you should use \192.168.1.2\
  • You must "escape" the character \ thus leaving \\192.168.1.2\DADOSTXT\arquivo.TXT
  • network / domain account

    If this does not solve the problem you will need to use a network / domain account for Apache to gain access:

  • Open the Start menu - > Run (or WindowKey + R) and type services.msc then press "Enter."
  • Search for the Apache service (or wampapache)
  • Right-click this service and select "Properties."
  • Go to the "LogOn" tab.
  • Select the "radio button" where it says "This account:", the fields will be enabled so enter the credentials so that you need apache to have access. If it is a domain / network account use the DOMAIN\nome-do-usuario syntax (or use the search to find the account using the "Browse ..." button)
  • Click OK and restart the Apache service (if it is wamp restart by wamp itself).
  • To check that the changes worked, go to the TaskManager (Task Manager or Ctrl + Alt + Del appears next to the Apache process (httpd.exe)
  • 17.06.2015 / 14:54