Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Created December 18, 2017 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damiencarbery/d18dfbb639c139441fe45f1660d08f9f to your computer and use it in GitHub Desktop.
Save damiencarbery/d18dfbb639c139441fe45f1660d08f9f to your computer and use it in GitHub Desktop.
List all files in and under the specified directory.
<?php
header("Content-Type: text/plain");
$root = './wp-content/uploads';
// From: https://stackoverflow.com/a/24784020/8605943
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator( $root ));
$files = array();
foreach ($rii as $file) {
if ($file->isDir()){
continue;
}
$files[] = $file->getPathname();
}
echo implode( "\n", $files );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment