Jump to content

Saving Files In Database


The Little Guy

Recommended Posts

There are pros and cons to storing actual files in the database vs storing the files on the file system and just putting a path reference in the database. We cannot answer whether that is a good idea or not without knowing the reasoning behind storing them in the DB. From my experience, storing the files in the filesystem is typically the best approach unless you have some specific reasons not to.

Well, it will definitely be slower since you will have to read the data from the database and then output the data appropriately. I'm not sure why you think it would think it is easier than just storing the path to a file. I tend to consider it a more complicated process.

 

As for more secure, that is debatable. If you don't want the files publicly accessible you should be storing the files outside the root directory of the site. You can then use PH to read those files from the file-system and pass on to the user when they request them.

In my opinion, unless there's a strong reason to be storing the files in the DB, you should store them on the file system.  That's what the file system was made for.

 

The discussion here goes over pros/cons of storing files in the DB:

http://programmers.stackexchange.com/questions/150669/is-it-a-bad-practice-to-store-large-files-10-mb-in-a-database

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.