Process file in forms

Process file in forms

by Raphael Goldman -
Number of replies: 1

Hi,

I have my own form with file attachment.

for example:

        $mform->addElement('filepicker', 'md_picture_big', get_string('md_picture_big'), null,
                    array('maxbytes' => $maxbytes, 'accepted_types' => '*'));

How can I move the file to a specific folder, and how can I get the file name?

I am only able to get a random number that moodle generates,

Thanks,

Raphael

Average of ratings: -
In reply to Raphael Goldman

Re: Process file in forms

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

If you are using the filepicker, you can get the file contents via $mform->get_file_content('userfile') ( http://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms#filepicker )

Unless you are wanting to process the file once then discard it, you should normally consider using the filemanager element instead. See the above docs page or https://github.com/davosmith/filemanager for more of an example.