Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Php, scandir not work for network folder?

Posted on 2010-08-12
6
Medium Priority
?
3,521 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

972 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