Filepicker: where do the uploaded files go?

Filepicker: where do the uploaded files go?

by Trolling in the Deep -
Number of replies: 1

Hello I want to create a simple uploader. In the filepicker, where can I find the DIRECTORY in which the file is going to be uploaded?

 

Thanks.

Average of ratings: -
In reply to Trolling in the Deep

Re: Filepicker: where do the uploaded files go?

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

The Moodle file API does not tell you the directory where the uploaded file will be stored. You can get the contents of the uploaded file like this:

$content = $mform->get_file_content('userfile')

See http://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms for more details.

Is there some reason why you particularly need the upload directory? If it is essential, then you can always create your own directory, then do something like this:

$fp = fopen($filename, 'w');
fwrite($fp, $contents);
fclose($fp);