开发者

php, mysql - folder/file organization for document management

I was wondering what would be the good way to organize documents in a filesystem for my php/mysql application. All info of the docs are stored in a db i am curious about filesystem organization. Is this good way to do it? Is there a better way?

Main folder

/documents

One folder per client

/documents/client1

Documents are uploaded here per client

/documents/client1/queue

After users fill the form docs are saved to a database and moved in this folder

/documents/client1/docs

Original and filesystem names of the document are stored in a database and filesystem name is something like 开发者_运维百科md5($time.$filename.$client_id) and the document path looks like this

/documents/client1/docs/6f99caa11e78697612d8f1b4481cd76a.pdf

I need (minimum) first page of pdf for the thumb and auto barcode reading from the first page

/documents/client1/docs/6f99caa11e78697612d8f1b4481cd76a/6f99caa11e78697612d8f1b4481cd76a-0.gif

I also have

/documents/client1/scan

where files from the scanner goes so users can import them in the database and after that they are renamed and moved to: /documents/client1/docs

I wonder if i should put files for specific date in a date folder like this:

/documents/client1/docs/20110915/6f99caa11e78697612d8f1b4481cd76a.pdf

Or should i use completely different folder structure?


Why not using only one common folder for temporary (uploaded) files ? It could make maintenance routine easier (for example deleting all old files).

I wonder if i should put files for specific date in a date folder like this:

/documents/client1/docs/20110915/6f99caa11e78697612d8f1b4481cd76a.pdf

If the date is handled by your database it's needless. Nevertheless if for some reason you need to access this file manually (not using your interface) it could be helpful...

Last but not least be aware of your filesystem's limitation. On some filesytem/os you could have a limitation on the number of file per folder (huge but still).


I would prefere a structure that hash the file organisation according to the file name.

/documents/6/f/9/6f99caa11e78697612d8f1b4481cd76a.pdf

This will keep good file access and its easy to make the structure deeper if needed.

The problem with using the date as a directory, is that the file location is dependant on some information that may change (we never know!)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜