Quesitons about File API

Re: Quesitons about 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
Glad to hear you've got it all working, but do be aware that those links do not describe ways that you should be writing code for a Moodle site.

For a Moodle site, AJAX calls should be via webservices: https://docs.moodle.org/dev/AJAX
You should never be touching $_POST directly in Moodle - always use the required_param() / optional_param() wrappers that make sure the data is cleaned before it is used (or required_param_array() / optional_param_array() if you need them).

Knowing how files are stored within moodledata is an interesting internal implementation detail (and it's a pretty cool storage mechanism) - but this should never be something you take into account when writing code to work with files in Moodle. Please make sure you're only accessing files by using the Moodle Files API, otherwise there's a good chance you'll manage to break your Moodle site at some point ...