Skip to content Skip to sidebar Skip to footer

[js]get File Names Of Apache Directory Listing

I am trying to get all the files of an Apache2 Direotry Listing to create AJAX-Requests tp each of them. But I can't find a RegExp to match in .

Solution 1:

$dir = 'http://www.example.com/directory';

$data = new DOMDocument();
@$data->loadHTMLFile($dir);
$links = array();
foreach($data->getElementsByTagName('a') as $link)
{
    $url = $link->getAttribute('href');
    if ($url[0] !== '?') // skip column links
    {
        $links[] = $url;
    }
}
print_r($links);

Post a Comment for "[js]get File Names Of Apache Directory Listing"