Core:File Class

From Habari Project

Jump to: navigation, search


Proposed Class: File


The File class implements the uploading and managing of files. These files can be attachments to a post, images, or a number of other purposes (inline mp3s, etc).


Storage: Files themselves are stored on the filesystem, in user/media/

Note: Should there be an option for separate directory partitioning here? Such as, user/media/mp3 or user/media/2007-03/?

Question: How do we tie this into multisites cleanly?


Posts: Files have a many to many relationship with posts. (A File can be associated with 0 or more Posts, and a Post can have zero or more Files attached to it)

Implementation detail: Would this be a row in postinfo, with name="file", value="[ID of the File]", or would we make a linking table for this?

Tagging: Files can be tagged and will have a many to many relationship to the tags table.


int - primary key
int - size of the file, in bytes (bigint maybe? int allows 4GB)
varchar - relative path to file from media/ root, including filename
varchar OR a foreign key to a file_types table
varchar - a name given to the file
int - foreign key to the user who uploaded the file
timestamp - date uploaded (different name suggested)

Shiny new Ideas

  • Do we want to maybe have full-text indexing of indexable documents like txt, html, pdf, doc, xls that get uploaded, so that we can then supply them with search results? Or is that a little too ambitious for a blogging app?
  • We should have a way for users to do mass uploads using FTP. umbrae suggested an incoming folder where the user uploads, then he visits the admin page so Habari can transfer them to the proper directory and add the relevent infos to the DB. This could be useful for people who migrate their sites.
    • Skippy suggested a better way, wherein there's no incoming folder, just the media folder which will detect new additions or deletions from the folder. If a new addition is detected, a notification will be shown on login, and if a file is found to be removed, the corresponding information will be deleted from the database. umbrae
This page describes a PHP class that is in the Habari software. For more comprehensive technical information visit the API Documentation.
Other Class Pages
Personal tools