Where are my files stored?
From EIRMA Wiki
| Quick Links |
|---|
|
Overview and Tutorial |
|
Pre-Installation Installation Post-Installation |
|
Administration |
|
Moderation Design Advanced |
|
Other |
Contents |
Introduction
By default, LDM expects to store and find any local files that it manages in subdirectories within the website directory structure. It is also possible to store the files outside the website directories, which will normally increase security. The following admin settings specify whereabouts LDM will store and access files:
- local_file_root
- When set to 'yes', the location of local files is specified relative to the root of local file system, instead of relative to the root of the website. Storing material outside the website makes it inaccessible to the prying user, but requires care to avoid opening up your server to malicious users.
- local_file_root_prefix
- This defines a prefix (e.g. '/downloads') to be inserted at the start of each local file name. This modifies the base point relative to which files are stored and located. This limits LDM's access to a particular part of the (web or local) directory tree, and thereby removes the possibility for users to create arbitrary links to files in other parts of your server.
LDM applies these two settings in sequence. Imagine you are trying to create an entry that points to file /fred/joe.pdf
- local_file_root is off and local_file_root_prefix is blank - LDM looks for a file http://yoursite/fred/joe.pdf
- local_file_root is off and local_file_root_prefix is /jim - LDM looks for http://yoursite/jim/fred/joe.pdf
- local_file_root is on and local_file_root_prefix is blank - LDM accesses /fred/joe.pdf in the top level directory on your web server. This potentially opens the entire file system to prying eyes.
- local_file_root is on and local_file_root_prefix is /jim - LDM looks in server directory /jim/fred/joe.pdf
The two settings apply throughout LDM. For example, directory scans and category synchronisations can only search parts of the directory tree within the space defined by local_file_root and local_file_root_prefix.
Warning: If you change these settings after loading files into your LDM database, you need to move the existing files into the new directories, so that the links remain valid.
Uploads
The setting uploads_dir specifies where uploaded files are stored.
This setting is interpreted after applying local_file_root and local_file_root_prefix, in other words, uploaded files may be stored in subdirectories of the web root or the file system.
Each upload is stored in a subdirectory of uploads_dir, constructed by splitting the user's userid into separate digits. In other words, if userid 123 uploads a file, the file will be stored in a subdirectory /1/2/3 underneath uploads_dir. The actual filename is a randomised number, in order to prevent collisions between different uploads that have the same filename.
Note: By contrast with the local_file_root and local_file_root_prefix settings, if you change the uploads_dir setting, there is no need to move existing uploads into the new directory in order to maintain valid links. If you do choose to move the files, it is necessary to edit their database entries to reflect the new locations. The "mass edit" functions in Administer->Categories provides a quick way to do this.
Thumbnails
The setting thumbs_dir specifies where image thumbnails are stored. Unlike uploads, the thumbs_dir setting always refers to a directory under the web root, because it would not otherwise be possible to optimise image display.
Again, each thumbnail is stored as a file in a subdirectory of thumbs_dir, constructed by splitting the user's userid into separate digits. In other words, if userid 123 uploads a file, the file is stored in a subdirectory /1/2/3 underneath uploads_dir. The actual filename is a randomised number, in order to prevent collisions between different uploads that have the same filename.
Warnings
- Do not enable local_file_root unless you have full control over your web server. Never turn this setting on without also setting local_file_root_prefix, otherwise you open up your entire server to prying eyes.
- If the PHP open_basedir setting is defined, LDM's access to files on the local server is always restricted. In this case, you must ensure that the values of local_file_root and local_file_root_prefix are consistent with the open_basedir setting.
