1
votes

Is it possible to list all the files from a remote server.I am running this code in serverOne.com , its a php server .I want to access serverTwo.com/dirOne its aTomcat server.

$path = "http://www.serverTwo.com/dirOne";

if ($handle = opendir($widget_path)) {
    while (false !== ($widgetfile = readdir($handle))) 
                         {
                if ($widgetfile != "." && $widgetfile != "..")
                                 {  
                   echo $widgetfile;     
                }
            }
            closedir($handle);
}
3

3 Answers

1
votes

If the other server has directory browsing enabled and there's no default document in the directory, then generally you get an HTML page containing a file listing. But if it's disabled and/or default-documented, then no, you can't. Not directly.

2
votes

The short answer is No. Definitely not like that because that would be a serious security problem, don't you think?!

There are ways you could establish a link between two servers but just allowing pretty much anyone to list files and read files off of one server from another would be quite bad.

1
votes

You can probably connect to your second server using FTP