Admin back end – get URL of file using file browser

You can scan the directory for files with glob() then loop throw the results and list them in a admin modal (thickbox) or just show the list within a admin metabox in the post editor.

Here’s a little snippet that i was playing with.

/**
 * Get HTML Article Files from uploads/articles
 * Support both .htm & .html ext.
 * 
 * @return array List of html article files with path & url.
 */
function wpse_384622_get_articles() {
    $uploads   = wp_upload_dir();
    $file_path = $uploads['basedir'] . '/articles/';
    $file_url  = $uploads['baseurl'] . '/articles/';
    $articles  = [];
    foreach ( glob( $file_path . '*.htm*' ) as $path ) {
        if ( is_readable( $path ) ) {
            $file_type = wp_check_filetype( $path );
            if ( 'text/html' === $file_type['type'] ) {
                $file_list[] = [
                    'path' => $path,
                    'url'  => str_replace( $file_path, $file_url, $path ),
                ];
            }
        }
    }
    
    return $articles;
}