0

I have found similar questions but the result didn't help me. I need to access - read, write, list files and dirs on computer in local network but php is not able to find or read it. I use this code

 $scandir = scandir("//192.168.101.22/somedir"); //returns false

And errors I got:

scandir(): (errno 2): No such file or directory

scandir(//192.168.101.22/somedir): failed to open dir: No such file or directory

I shared this folder on LAN computer with full access for Everyone. When I open this location in Total Commander, there is no problem. Also I created a shared folder on the computer where PHP is located and PHP found this folder. I tried to use backslashes or file:, nothing helped me.

PHP version: 5.4.16

Wamp server 2.4

Windows 8.1 (where WAMP is located)

Windos 7 pro (computer on LAN)

Community
  • 1
  • 1
mesnicka
  • 2,148
  • 7
  • 19
  • 29
  • You need to impersonate the windows user to gain access. PHP has a different user than the current user. – Taha Paksu Jul 17 '17 at 07:29
  • Well, this sounds logical. I found solutions for IIS and fastcgi. Can you help me with impersonate for WAMP? – mesnicka Jul 17 '17 at 07:54
  • If you are using PHP locally, try adding `wwwuser` or `www-user` or which user php uses to create/access files to the Users group. I don't know what'll happen, but it's something to try while we find a solution with apache/php. – Taha Paksu Jul 17 '17 at 07:57
  • Here in this answer is something more logical described: https://stackoverflow.com/a/1154182/916000 Try running your script with console. – Taha Paksu Jul 17 '17 at 08:04
  • What you can do is first open explorer (f4 -> address) and login from there. I was too getting this error, I used this approach. – Th3 Jul 17 '17 at 08:17
  • https://stackoverflow.com/questions/7431658/apache-network-drive-alias – RiggsFolly Jul 17 '17 at 08:25
  • Thanks for all answers. The final solution for me is https://stackoverflow.com/a/4944044/382854 – mesnicka Jul 17 '17 at 08:54

0 Answers0