Filepicker: where do the uploaded files go?

Filepicker: where do the uploaded files go?

Trolling in the Deep -
回帖数: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.

回复Trolling in the Deep

Re: Filepicker: where do the uploaded files go?

Davo Smith -
Core developers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 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);