开发者

Access dir from remote server in php?

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 != "." &&开发者_C百科 $widgetfile != "..")
                                 {  
                   echo $widgetfile;     
                }
            }
            closedir($handle);
}


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.


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.


You can probably connect to your second server using FTP

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜