Solved

Php, scandir not work for network folder?

Posted on 2010-08-12
6
2,984 Views
Last Modified: 2013-12-13
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?
0
Comment
Question by:zcfyhome
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:RealityLord
ID: 33424908
Try to use single quotes instead double quotes.

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

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

echo "Second scandir\r\n";

$files = scandir("\\\\server\share");
var_dump($files);
?>

This is script output (edited to remove filenames):
First scan dir
array(11) {
  [0]=>
  string(1) "."
  [1]=>
  string(2) ".."
  [2]=>
  string(7) "*******"
  [3]=>
  string(8) "********"
  [4]=>
  string(4) "********"
  [5]=>
  string(10) "**********"
}
Second scandir
bool(false)

Obviously, while using double quotes, php tries to evaluate content between them, and there is somw screw up.
Hope this helps
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33426602
Can you list those folders with Windows Explorer without any problems?
0
 

Author Comment

by:zcfyhome
ID: 33428835
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?

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:zcfyhome
ID: 33433119
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?
Thanks
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 33434214
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.
0
 

Author Closing Comment

by:zcfyhome
ID: 33782156
Ok, I think it's no way to select account to access network share folder.
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now