Solved

Php, scandir not work for network folder?

Posted on 2010-08-12
6
3,154 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 83

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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Featured Post

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!

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

752 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