Ok, I’m building a forum (I know there are several excellent free, off the shelf, open source forum apps out there, but I’m the kind of guy who wants to build his house rather than buy it ?) and I’m setting it up now to allow attachments to posts. I am trying to figure out the best way of going about this:
I can store the attachment as a file on the server
I can store the attachment as a BLOB in the database
A significant population of developers (of which I am one) think binary information has no place in a database so I am trying to work my way through storing the files on the server but I am encountering a theoretical problem:
Where do I store the attachments so that I can be sure that when one user uploads a file, it won’t overwrite a previous attached file of the same filename?
I was considering storing them in separate folders according to the id of the thread they were posted in, but that doesn’t exclude the possibility of two attachments with the same name in the same thread, then I thought of creating a folder with the unique postid and store the attachment in there, but creating a new folder for every post with an attachment seems like overkill.
How does webdeveloper.com do it? Does anyone have any suggestions?
NOTE: I DO NOT want to alter the file name of the file that was attached in anyway, if I didn’t mind doing that, then this problem would be easy to solve.
Thanks.