Solved

Php, scandir not work for network folder?

Posted on 2010-08-12
6
2,941 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
Comment Utility
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 82

Expert Comment

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

Author Comment

by:zcfyhome
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:zcfyhome
Comment Utility
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 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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
Comment Utility
Ok, I think it's no way to select account to access network share folder.
Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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.

743 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

13 Experts available now in Live!

Get 1:1 Help Now