Take the 2-minute tour ×

I am trying to use scandir() to get the list of files for a directory.

function getFileList($directory) {
    //Get the listing of the files/folders within the directory, place into an array.
    $files = scandir($directory);
    //Remove . and .. from the array.
    //Reindex array.
    $files = array_values($files);

    return $files;

$directory = '//';
    $files = getFileList($directory);


Using this code works great when run from my local machine ( but when run through the company intranet ( I get the following warnings which keep my script from running:

Warning: scandir(// [function.scandir]: failed to open dir: Invalid argument in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 4

Warning: scandir() [function.scandir]: (errno 22): Invalid argument in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 4

Warning: array_values() [function.array-values]: The argument should be an array in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 9

I can the run dialog in windows and enter // when using the box and it does open Windows explorer at the proper location, so that machine is able to find the requested address.

Can someone help me with what I'm missing to get this working locally and via the intranet. Thank you in advance for any light that you may be able to shed on the situation.

share|improve this question
Have you checked out this past thread? It may help. stackoverflow.com/questions/1153824/… –  Wavy Davy Sep 10 '12 at 20:43

1 Answer 1

I don't know about reading folders via network like this, but wouldn't it be possible for you to map a network drive instead and try scandir() on that drive?

share|improve this answer
Unfortunately even with it as a mapped drive it returns the same warnings. –  Jeremy1026 Sep 11 '12 at 13:25

Your Answer


