[英]PHP - What is the best practice for getting the ftp list from the remote server?
[英]Getting File and Folder List from Remote Server in PHP
當我跑:
$url='foldername';
$dir = opendir($url);
//List files in images directory
while (($file = readdir($dir)) !== false)
{
echo "filename: " . $file . "<br />";
}
closedir($dir);
......它輸出:
filename: a.gif
filename: file.html
filename: g.gif
filename: gg.html
我想從URL看到另一台服務器上的所有文件和文件夾:
$url="http ://example.com"
如何從example.com
找到文件和文件夾名稱?
有可能的。 剛開出盒子。 唯一的缺陷就是索引輸出
<?
$matches = array();
preg_match_all("/(a href\=\")([^\?\"]*)(\")/i", get_text('http://www.website.com/ images/'), $matches);
foreach($matches[2] as $match)
{
echo $match . '<br>';
}
function get_text($filename)
{
$fp_load = fopen("$filename", "rb");
if ( $fp_load )
{
while ( !feof($fp_load) )
{
$content .= fgets($fp_load, 8192);
}
fclose($fp_load);
return $content;
}
}
?>
http://
不支持目錄列表。 你要做的事是不可能的。
當然這是不可能的,否則網站會更容易被攻擊,因為任何人都可以探索他們的目錄樹!
如果您有其他方式訪問該網站(例如,如果它是您的),如FTP或SSH,它就成為可能。
也許用PHP是不可能的..但有r程序可以做你想做的事情。 “intellitamper”就是其中之一。 http://www.softpedia.com/get/Internet/Other-Internet-Related/IntelliTamper.shtml < - 鏈接。
否則它將是天堂......任何人都可以破解任何網站。
這應該在某些服務器上正常工作
function get_text($filename) {
$fp_load = fopen("$filename", "rb");
if ( $fp_load ) {
while ( !feof($fp_load) ) {
$content .= fgets($fp_load, 8192);
}
fclose($fp_load);
return $content;
}
}
$matches = array();
preg_match_all("/(a href\=\")([^\?\"]*)(\")/i", get_text('https://www.example.com/'), $matches);
foreach($matches[2] as $match) {
echo $match . '<br>';
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.