Hi,
I try to learn how can build a block under moodle 2.x so do everything from the 2 tutorial (Basic, Advenced). But I have a big question. The tutorial make a form with filepicker but not it show, how can i download in a viewpage this file.
I tried download it with File API. I writed this code:
$fs = get_file_storage();
//$task->reportedid content that userid who send a form another page like in the tutorial
$context = get_context_instance(CONTEXT_USER, $task->reporterid);
$files = $fs->get_area_files($context->id, 'user', 'draft', $task->filename);
foreach ($files as $file) {
$filename = $file->get_filename();
$url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename(), TRUE); $out = html_writer::link($url, $filename); echo $out; }
The generated url: http://localhost/moodle/pluginfile.php/5/user/draft/353424072/Desert.jpg?forcedownload=1
but the Moodle says, there is not a file. L
How can I do that: somebody send a form with a file (like the tutorial), and other person who watch the sended data in a table can download it via a link.
Thanks your answer