php、mysql - 用于文档管理的文件夹/文件组织
我想知道在我的 php/mysql 应用程序的文件系统中组织文档的好方法是什么。文档的所有信息都存储在数据库中,我对文件系统组织很好奇。这是好方法吗?有更好的办法吗?
主文件夹
/documents
每个客户端一个文件夹
/documents/client1
每个客户端将文档上传到此处
/documents/client1/queue
用户填写表单后,文档将保存到数据库并移动到此文件夹中
/documents/client1/docs
文档的原始名称和文件系统名称存储在数据库中,文件系统名称类似于 md5($time .$filename.$client_id)并且文档路径看起来像这样
/documents/client1/docs/6f99caa11e78697612d8f1b4481cd76a.pdf
我需要(最小)pdf的第一页用于拇指和从第一页自动条形码读取
/documents/client1/docs/6f99caa11e78697612d8f1b4481cd76a/6f99caa11e78697612d8f1b4481cd76a-0.gif
我也有
/documents/client1/scan
来自扫描仪的文件所在的位置,以便用户可以将它们导入数据库以及之后它们被重命名并移动到: /documents/client1/docs
我想知道是否应该将特定日期的文件放入这样的日期文件夹中:
/documents/client1/docs/20110915/6f99caa11e78697612d8f1b4481cd76a.pdf
或者我应该使用完全不同的文件夹结构?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不只使用一个通用文件夹来存放临时(上传)文件?它可以使日常维护变得更加容易(例如删除所有旧文件)。
如果日期由数据库处理,则不需要。不过,如果由于某种原因您需要手动访问此文件(不使用您的界面),它可能会有所帮助...
最后但并非最不重要的一点是要注意您的文件系统的限制。在某些文件系统/操作系统上,您可能对每个文件夹的文件数量有限制(虽然很大但仍然如此)。
Why not using only one common folder for temporary (uploaded) files ? It could make maintenance routine easier (for example deleting all old files).
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.
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!)