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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.