当我跑:
$url='foldername';
$dir = opendir($url);
//List files in images directory
while (($file = readdir($dir)) !== false)
{
echo "filename: " . $file . "<br />";
}
closedir($dir);
Run Code Online (Sandbox Code Playgroud)
......它输出:
filename: a.gif
filename: file.html
filename: g.gif
filename: gg.html
Run Code Online (Sandbox Code Playgroud)
我想从URL看到另一台服务器上的所有文件和文件夹:
$url="http ://example.com"
Run Code Online (Sandbox Code Playgroud)
如何找到文件和文件夹名称example.com?
小智 8
有可能的.刚开出盒子.唯一的缺陷就是索引输出
<?
$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;
}
}
?>
Run Code Online (Sandbox Code Playgroud)