Strange php opendir/glob issue

1.3k Views Asked by At

I have a strange issue with opendir (same problem with glob):

$dir = "Y:\\\\foldername\\";
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            echo "filename: $file\n";
        }
        closedir($dh);
    }
}

Y:\ is a network folder with authentication. My webserver name is testweb and this script is called tree.php. Unfortunately my environment is windows based (php 5.2.5 ISAPI, windows 2003 server).

When I open the script from the same machine where IIS is running (http://testweb/tree.php ) everything works fine but if I connect to the same address from another machine (eg my laptop) I get the following error:

Warning: opendir().. failed to open dir. No error IN D:\web\tree.php

It seems a permissions issue but why it is working from the "local machine" and not from outside? How can I fix this?

Thanks for your help!!

2

There are 2 best solutions below

3
On

check your permissions on that directory.. you can do it using the function called is_readable

0
On

I had this error before even when I changed the permission and I logged in as admin the error persisted.

I solved this by giving the absolute path for the function opendir() that is instead of writing "subfolder" I wrote "C:\wamp\www\myproject\subfolder" and this solved my problem !

Thanks