opendir cannot read network drives

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

opendir cannot read network drives

Post by malcolmboston »

currently using this function (which works perfectly) for listing files in a folder

Code: Select all

function readDirectory ($dirPath) {
   if ($handle = opendir($dirPath)) {
      while (false !== ($file = readdir($handle))) {
         if ($file != "." && $file != "..") {
            if (!isset($i)) {
               $i = 1;
            }
            $array[$i] = $file;
            $i++;
         }
      }
      closedir($handle);
   }
   return $array;
}
now on my machine i have access to a shared drive named on mine

Code: Select all

c on 'andys (Your-j9bfddr9va)'
// labelled as Z:
whenever i tell PHP to read it it wont, why is this? i cant even read the base of Z but when i change to C it works fine which leads me to think PHP wont allow it or its a windows thing and i need to change a setting

Anyone any ideas?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

drive mapping is profile specific. Meaning that whatever you're logged in as is the only thing that's going to see your Z: drive. If you log out and back in as a different user, that drive wont' be mapped (unless you've specifically mapped it for that user as well).

because the web user is a different user, it doesn't have a drive mapped to Z: like you do.

you could try using a the full UNC path, but I think I've tried this in the past and didn't have success.

I can't remember off the top of my head how (if) I resolved it so I'll look back at some old code and let you know....
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

cheers burrito! :D
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

:bump:

anyone?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I couldn't find my solution but I'm nearly 100% certain that I did it like this:

Code: Select all

glob("\\\\myserver\\myshare");
you'll have to give EVERYONE read permission on the share.
Post Reply