adding file to moodle 2.73 from code

adding file to moodle 2.73 from code

by avi levi -
Number of replies: 2

Hi all

i am writing a page that among other things should add a file to the scorm activities in my/other sites.

the page has no UI.

when it is activated it automaticaly supposed to find all scorms in the site and add them a file.

how do i add a file to moodle 2.73.

i know that each file has a record in the mdl_files table and it is renamed and placed in the [moodle_data]/filedir according to that record but how do i create that record??


Thank you for any help

Average of ratings: -
In reply to avi levi

Re: adding file to moodle 2.73 from code

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

This is a good starting point: https://docs.moodle.org/dev/File_API

You should also take a look at the code in lib/filestorage/file_storage.php to see the different types of 'create_file_...' functions available.


In reply to Davo Smith

Re: adding file to moodle 2.73 from code

by avi levi -

Thank you i started to brows the page and it does help