Php, scandir not work for network folder?

I using scandir get the folder files list,
scandir("c:\\myfolder")    works.
But for network folder give me error "failed to open dir: Invalid argument"
Like scandir("\\\\servername\\myfolder"),   not works
even I map the server to J:
 scandir("J:\\myfolder"),  not work.
rename function also have same problem.
Any idea about these ?  any permit need set?
TimSenior PHP DeveloperAsked:
Who is Participating?
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
I don't know the answer to your last question but I had the same problem trying to access shares on another computer.  I had to stop and go do something else at that point and didn't have time to tell you about it.
Try to use single quotes instead double quotes.

I tried this script:
echo "First scan dir\r\n";

$files = scandir('\\\\server\share');

echo "Second scandir\r\n";

$files = scandir("\\\\server\share");

This is script output (edited to remove filenames):
First scan dir
array(11) {
  string(1) "."
  string(2) ".."
  string(7) "*******"
  string(8) "********"
  string(4) "********"
  string(10) "**********"
Second scandir

Obviously, while using double quotes, php tries to evaluate content between them, and there is somw screw up.
Hope this helps
Dave BaldwinFixer of ProblemsCommented:
Can you list those folders with Windows Explorer without any problems?
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

TimSenior PHP DeveloperAuthor Commented:
Yes, I can list those folders with windows explorer.

I checked double quotes issues, it works on scandir("\\\\server\share")
But my sharefolder have numbers name
like  \\\\server\share\60000s, it doesn't work.
also  \\\\server\share\\60000s,  it doesn't work.
Any help?

TimSenior PHP DeveloperAuthor Commented:
Maybe I found the problem,
It looks permit problem, php using User account
I check the folder 'share' have the User account there,
But subfolder do not have the User account there in security.
How can I switch php run one windows account to access this?
TimSenior PHP DeveloperAuthor Commented:
Ok, I think it's no way to select account to access network share folder.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.