Database Setup
The file manager stores two things: the physical file on disk (uploaded to a module directory) and a database record that indexes it. The database record holds metadata - the document name, the generated filename, the filesystem path, the file size, and the MIME type.
The Table
CREATE TABLE IF NOT EXISTS `file_manager` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`doc_name` varchar(255) NOT NULL,
`file_name` varchar(100) NOT NULL,
`file_path` varchar(255) NOT NULL,
`file_size` int(11) NOT NULL DEFAULT 0,
`file_type` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;The columns break down as follows:
| Column | Purpose |
|---|---|
id |
Primary key, auto-increment. Used as the record identifier throughout the module. |
doc_name |
A human-readable name entered by the user during upload (e.g., "Annual Report"). |
file_name |
The actual filename on disk (e.g., report_k3m9n1.pdf). This is a random 10-character name generated by the File module. |
file_path |
The relative filesystem path to the file (e.g., ../modules/file_manager/files/report_k3m9n1.pdf). |
file_size |
The file size in bytes, as returned by $this->file->upload(). |
file_type |
The MIME type of the file (e.g., application/pdf). |
Why Store Both doc_name and file_name?
The doc_name is user-facing: "Q3 Budget Report," "Meeting Notes," "Signed Contract." The file_name is a randomly generated string on disk, which prevents users from guessing file URLs and guards against filename collision. Storing both means you can display a friendly name to users while keeping the secure random name on the filesystem.
The file_path column stores the complete relative path returned by upload(), which allows you to use it directly with other File module methods like delete(), exists(), and download().
Sample Data
The repository's file_manager.sql includes sample records if you want to test the file list immediately. Note that the sample records reference files that do not actually exist on disk - they are for demonstrating the manage page and show page only.
We're continually improving the Trongate documentation. If anything is incorrect, unclear, incomplete, or could be better, we'd genuinely appreciate your input.
Share your thoughts in the Documentation Feedback.