Moodle upload file plugin development

Moodle upload file plugin development

by Teguh Rijanandi -
Number of replies: 2

Hi guys, i'm newbie here. I have problem here about plugin development

i'm already coded my mod_form like this

https://github.com/teguh02/moodle-cloudinary/blob/master/mod_form.php

How to get file element value (see code below)

https://github.com/teguh02/moodle-cloudinary/blob/ffee4a998c34e556de528917aefaff463a6e6eab/mod_form.php#L17

to my lib.php? (see code below)

https://github.com/teguh02/moodle-cloudinary/blob/ffee4a998c34e556de528917aefaff463a6e6eab/lib.php#L11-L14

i'm already using $_FILES and $_REQUEST but my moodle show error message.

Anyone can help me please?

Average of ratings: -
In reply to Teguh Rijanandi

Re: Moodle upload file plugin development

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
The Files api is complex, but I can confirm that using
$_FILES and $_REQUEST is not advised
Reading the code for other plugin is my best advice, I wish I had better advice sad
In reply to Teguh Rijanandi

Re: Moodle upload file plugin development

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I would go further - DON'T use $_FILES and $_REQUEST. If you are, you are doing it wrong. Moodle has a straightforward API for uploading files (depending what you plan to do with them)