views:

44

answers:

2

I'm going to incorporate the feature for my users to upload small files which are under 2mb (jpg, gif, pdf and docs). For page loading times purposes and generally managing files in future, can you recommend is it best to have the files uploaded to the filesystem (and link to it via the database) or upload to the database directly as a BLOB?

Thanks for any help. Dan

+1  A: 

From my point of view, file system is the best choice.

  1. Your database is not getting oversized because of BLOB fields
  2. You store only filenames as strings and you possibly can index on them (if you give meaningful names to your files)
  3. If you run out of space it is much easier to plug new HDD than migrate your DB.

The only drawback here is that someone (even you) can accidentally delete files much easier than BLOB fields.

Bashir Magomedov
"If you run out of space it is much easier to plug new HDD than migrate your DB." - with some DBMSs, you can increase the database size available simply by adding disk space.
Mark Bannister
A: 

There are pros and cons for both approaches. Keeping files in DB will make management much simpler. From another side, files stored on filesystem can be delivered more effectively, saving IO and CPU resources.

Dmitry Khalatov
What if there were thousands of file uploads, each linked to a persons account - would putting them all in one folder cause issues on the filesystem or would they need to be sorted in separate folders?
Dan