I created a new activity and i uploaded a file correctly within it but when i used
$url = moodle_url::make_pluginfile_url($file->contextid, $file->component, $file->filearea, $file->itemid,$file->filepath, $file->filename);
to get the link the result is : Sorry, the requested file could not be found
I searched an I find that I have to add a pluginfile function in my lib and this is my function :
function testnew_pluginfile($course, $cm, $context, $component, $filearea, $itemid, $path, $filename) {
global $CFG, $DB;
require_course_login($course, true, $cm);
$fullpath = "/{$context->id}/$component/$filearea/$itemid/$path/$filename";
$fs = get_file_storage();
if (!$file = $fs->get_file_by_hash(sha1($fullpath))) {
return false;
}
send_stored_file($file, 0, 0, false);
}