Skip to main content
Version: main

File Browser API

The File Browser API is a supplemental API which can be used to fetch information relating to Files stored in the Moodle File API.

Fetch a series of breadcrumbs to the requested file

This example demonstrates using the filebrowser API to fetch the parent folders of a file.

public function get_file_breadcrumbs(\stored_file $file): ?array {
$browser = get_file_browser();
$context = get_system_context();

$fileinfo = $browser->get_file_info(

if ($fileinfo) {
// Build a Breadcrumb trail
$level = $fileinfo->get_parent();
while ($level) {
$path[] = [
'name' => $level->get_visible_name(),
$level = $level->get_parent();

$path = array_reverse($path);

return $path;

return null;