Fetch a file and display it using the File API

Re: Fetch a file and display it using the File API

by Davo Smith -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You need to make sure you're using the file_prepare_standard_editor() and file_postupdate_standard_editor() functions ( https://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms#editor ) to a) copy files in and out of the draft area when entering / exiting the form and b) rewrite all URLs embedded in the form text data to/from the draftfile.php versions.

Any of the core forms that allow file uploads in the editor do this, so there are lots of examples throughout the standard Moodle code.