Page 1 of 1

File Management

Posted: Fri Aug 07, 2009 11:22 pm
by omniuni
Let's say I want a file manager with the following features:

Upload, tag, sort, search by name or tag, and download from a link.

Basically, I want to get my files information in a DB so that I can do stuff with it. One easy way to do this is to rename every file to its MD5, and then manage the rest of the info by DB. These make messy links. Then, I am thinking of using a file proxy... some "file.php" script that would instead be the file to download, it would take an argument, and deliver the requested file. This seems nice and neat, allows me to track files by their hash, and you can alias files to make simple links. Is this a bad idea, or is it particularly difficult to make a file proxy script? Is there another way to track the files as they are uploaded? I don't like the idea of just using names, because when you rename the file, you also have to update the DB. Is this just.... how is HAS to be done?

Oh well, I'm getting tired! Any ideas and feedback are appreciated.

Re: File Management

Posted: Sat Aug 08, 2009 1:43 am
by kaisellgren
A file proxy script is a good idea. Every file should have a unique identifier that is being passed when downloaded (e.g. download.php?f=1234). The identifier does not need to be a number, it can consist of anything you want. You could create a column "id" in the database that is x bytes in length and generate unique identifiers upon file uploads. Some people just use auto incrementing identifiers in databases and pass the identifier in the URI like download.php?file=1234, but you can have other characters as the identifier, too. Using random identifiers rather than automatically incrementing identifiers has the effect of not giving any clues about your files (e.g. you can't say weather file "a95ghfs3" is older than file "dfg94gk3").