Hi all, I am trying to connect to a remote server, I am using the IP address server name and folder to connect, not sure if ths is working?
I am aslo getting an error on the final foreach loop (foreach ($files as $file) {//print array
) Warning: Invalid argument supplied for foreach() in C:\wamp\www\open_dir\index.php on line 50.
Any help would be received would be appriciated
Thanks in advance
David
function filelist ($startdir="./http://IPaddress/WATKINS-TS\Webserv/", $searchSubdirs=1, $directoriesonly=0, $maxlevel="all", $level=1) {
//list the directory/file names that you want to ignore
$ignoredDirectory[] = ".";
$ignoredDirectory[] = "..";
$ignoredDirectory[] = "_vti_cnf";
global $directorylist; //initialize global array
if (is_dir($startdir)) {
if ($dh = opendir($startdir)) {
while (($file = readdir($dh)) !== false) {
if (!(array_search($file,$ignoredDirectory) > -1)) {
if (filetype($startdir . $file) == "dir") {
//build your directory array however you choose;
//add other file details that you want.
$directorylist[$startdir . $file]['level'] = $level;
$directorylist[$startdir . $file]['dir'] = 1;
$directorylist[$startdir . $file]['name'] = $file;
$directorylist[$startdir . $file]['path'] = $startdir;
if ($searchSubdirs) {
if ((($maxlevel) == "all") or ($maxlevel > $level)) {
filelist($startdir . $file . "/", $searchSubdirs, $directoriesonly, $maxlevel, $level + 1);
}
}
} else {
if (!$directoriesonly) {
//if you want to include files; build your file array
//however you choose; add other file details that you want.
$directorylist[$startdir . $file]['level'] = $level;
$directorylist[$startdir . $file]['dir'] = 0;
$directorylist[$startdir . $file]['name'] = $file;
$directorylist[$startdir . $file]['path'] = $startdir;
}}}}
closedir($dh);
}}
return($directorylist);
}
$files = filelist("./",1,1); // call the function
foreach ($files as $file) {//print array
echo "Directory: " . $file['dir'] . " => Level: " . $file['level'] . " => Name: " . $file['name'] . " => Path: " . $file['path'] ."<br>";
}?>