as a Moodle admin I am asked to delete a file in Moodle. The file contains misleading information and has to be completely removed as soon as possible. The only information I have is the file URL. That looks like that:
As moodle administrator how can I remove the file, how can I see, where it is used? Any information would be very helpful.
If you don't mind digging through the database, you can find it by looking in mdl_files for the record:
- contextid = '9445'
- component = 'mod_page'
- filearea = 'content'
- itemid = '70'
- filename = 'FAQ.pdf'
- filepath = '/'
(If you just search by contextid, you should find it pretty quickly anyway)
Once you have that record, if you want to make sure the file is gone from the server, look at the 'contenthash' field, then use that to locate the file in the '[dataroot]/filedir' directory on your server (within there, it has a directory named after the first 2 characters of the contenthash, then another named after the next 2 characters, then the file - e.g. contenthash= 'a4f146f120e7e00d21291b924e26aaabe9f4297a' is found in '[dataroot]/filedir/a4/f1/a4f146f120e7e00d21291b924e26aaabe9f4297a'). You can delete the file there, then delete any records in the database that have that same contenthash and it will definitely be gone (but there may still be some broken links to it, if you can live with that).
Obviously, be very careful and double-check everything before you do any of the above!
thank you for that explanation. In fact, it would be no problem to do that if I had access to the file system, but unfortunately for this particular instance I am only administrator. That means, I have access to the site via the moodle interface only.
Maybe installing a reports plugin like one of these
and then create custom SQL queries would help to find the course links / activity links / ressources links. Then delete the locations found by the query.