简体   繁体   中英

php - check if files exists in folder on network/lan

I want to check if files exists in the network folder (eg. path = "U:\\abc\\def\\") using php.

I tried to use following:

if(file_exists("U:/abc/def/400abc.doc")) {
    echo "YES";
} else {
    echo "NO";
}

I get NO. I also tried path = "//abc-drive/folder-main/abc/def/400abc.doc" but still it doesn't work.

The files are on a network/shared folder and NOT in subfolders from where php server runs

Can anyone please tell HELP?

Regards

This won't work if PHP has safe_mode enabled. Try setting safe_mode_include_dir to add an exception, and reference the location with the syntax \\\\computername\\share\\filename .

Use the URI format. file://U:/abc/def/400abc.doc

Change FASTCGI Setting in server [FASTCGI Setting] -> open ...php-cgi.ex -> FastCGI Property -> Advanced Setting -> protocol -> Change [NamedPipe] to [TCP]. I have same error with you, I tried it and success. GoodLuck

If file_exists is returning false for a file or folder on a Windows network drive, try the following:

  1. Run regedit.exe
  2. Locate the following key - HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Parameters\\RestrictNullSessAccess
  3. Change its value from 1 to 0.
  4. Restart your computer.
  5. Double check your network drive is connected.
  6. Retry your script - this time file_exists should return true.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM