Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Php, scandir not work for network folder?

Posted on 2010-08-12
6
Medium Priority
?
3,407 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:Tim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 84

Expert Comment

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

Author Comment

by:Tim
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Tim
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 84

Accepted Solution

by:
Dave Baldwin earned 1000 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:Tim
ID: 33782156
Ok, I think it's no way to select account to access network share folder.
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

715 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