Where are forum attachments stored?

Where are forum attachments stored?

by Roger Cooper -
Number of replies: 3

Where are forum attachments stored and are they stored in unencrypted files? I need to find what happened to some Moodle 1.9 forum attachments that seem to have disappeared. I would like to see if they can be found and viewed in the server folder structure.

Average of ratings: -
In reply to Roger Cooper

Re: Where are forum attachments stored?

by Guillermo Madero -

Hi Roger,

You should find them under the moodledata directory (its location is defined in the $CFG->dataroot directive at the config.php file):

http://docs.moodle.org/19/en/Moodledata_directory

In reply to Guillermo Madero

Re: Where are forum attachments stored?

by Roger Cooper -

I guess I should have said I know they are in moodledata. I just do not know exactly where in moodledata.

I have been told that file names are hashed to be unrecognizable and want to see if that is accurate information.

In reply to Roger Cooper

Re: Where are forum attachments stored?

by Guillermo Madero -

Hi Roger,

Sorry for stating the obvious, but it isn't when it isn't.

Are we then talking about a Moodle 2.x installation? Because you never mentioned that.

If you're working with 1.9, then the directory structure uses the course ids (e.g. everything under directory 123 belongs to course 123).

If you're working with 2.x, then you need to access the mdl_course table, look for the original file name of the attachment and use the content hash value to locate both the directory and the file. So, if the original file was named "somefile.pdf" and its content hash is something like "d789ab34...", you would then use the leftmost first four characters to determine the location, like so:

moodledata/filedir/d7/89

and there you would find file "d789ab34...".

Files are not encrypted.

--- Reference

http://docs.moodle.org/dev/File_API_internals#File_API_internals