Question

I'm working on a sitemap script but now I need to know how I can scan all my photo's since they are in different folders (I'm working with albums) All my images that I want to get into the sitemap are in this directory: public_html/Albums/{Albumname}/{photo name}

How can I do this?

Was it helpful?

Solution

If the location in not remote then you can try the following:

<?php
$path = realpath('public_html/Albums');
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename)
{
        echo "$filename\n";
}
?>

You can generate the URL accordingly in the loop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top