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:
- Run regedit.exe
- Locate the following key - HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\RestrictNullSessAccess
- Change its value from 1 to 0.
- Restart your computer.
- Double check your network drive is connected.
- Retry your script - this time file_exists should return true.
精彩评论