EXEC function not returning values
I wrote a PHP page that goes out and searches a directory on our main fileserver for files that match search criteria a user inputs. I use the exec() function to run the search, and have the results returned into an array of $find_output. This page and function worked last week, but is not anymore for some reason. Here is the code:
$directory = "N:\\Dir1\\SubDir1\\SubDir2\\SubDir3";
$fname = preg_replace('/[^a-zA-Z0-9\-]/', '', $filename);
$fname = $fname."*.*";
$dirname = "$directory\\$fname";
$find_output = array();
exec("dir $dirname /s /a:-d /b",$find_output);
print_r($find_output);
The $filename is the file name that they are looking for, such as "bkb333". The "print_r($find_output)" statement just returns Array(). But I run the dir statement in a cmd window, and it returns 5 files. Any suggestions? Or examples of how I can do this better? I need to output a list of files returned from the search so that the user can select which ones they want, and have them emailed to them. Any better way to do this would be appreciated.
|