Display filepicker's file ??

Display filepicker's file ??

by Julien Thomas -
Number of replies: 3

Hi,

I'm trying to develop my own block and I first followed theses tutorials to learn how to do it correctly :

http://docs.moodle.org/dev/Blocks

http://docs.moodle.org/dev/Blocks_Advanced

 

I've attached the final block to this topic.

 

For the moment this block stores an INT in the database when I submit the form.

It looks like it is the id of the file in a draft directory, and the url of the file in the filepicker is something like :

{myWebsite}/draftfile.php/5/user/draft/605087011/{Filename}.pdf

 

I would like to display the uploaded file name and a link to download it on the view.php page.

 

I studyed some APIs like theses :

http://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms#Using_the_filepicker_element

http://docs.moodle.org/dev/File_API

 

But nothing seems to work like I want.

When I want to get the name of the file chosend by the filepicker with :

$name = $mform->get_new_filename('filename');

The function get_new_filename is not found and otherwise I get a blank screen.

 

Can someone help me or give me some advices ?

 

Thank you

 

Julien

 

Average of ratings: -
In reply to Julien Thomas

Re: Display filepicker's file ??

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you're asking someone to upload a file that you are then going to keep, then you should be using a filemanager, not a filepicker element (filepickers are really only wanted when you grab the content of the file, import or otherwise process the content, then discard the original file).

Andrew Normore's got a reasonably simple example of using a filemanager here: https://github.com/AndyNormore/filemanager

 

Average of ratings: Useful (2)
In reply to Davo Smith

Re: Display filepicker's file ??

by Julien Thomas -

I didn't manage to make AndyNomore,s work working in a block yet, but I have another question now :

Is it possible to view and edit user private files ?

 

If some user with a particular role could edit in a file manager or view the private files of student it would be perfect !

I'd make a block similar to 'private files', high roles could manages the files and some others just view it.