I am trying to access below code in my local folder which I have created separately. I am writing custom web services, which will help me to get data images of all quiz. I have copied below code from https://docs.moodle.org/dev/File_API. I am getting an error "
Notice: Trying to get property of non-object in /home/onlin200/public_html/lib/filebrowser/file_browser.php on line 78".
Do I have to include library while implementing this code?
$browser = get_file_browser();
$filename = "draftfile.php";
$component = "user"; //if activity: database
$filearea = "draft";
$itemid = 824469588;
$context = 598;
if ($fileinfo = $browser->get_file_info($context, $component, $filearea, $itemid, '/', $filename)) {
// build a Breadcrumb trail
$level = $fileinfo->get_parent();
while ($level) {
$path[] = array('name'=>$level->get_visible_name());
$level = $level->get_parent();
}
$path = array_reverse($path);
$children = $fileinfo->get_children();
foreach ($children as $child) {
if ($child->is_directory()) {
echo $child->get_visible_name();
// display contextid, itemid, component, filepath and filename
var_dump($child->get_params());
}
}
}