0

I want to save the profile picture, and I want to know what is the best option.

-Saving the path in the DB and load the image according to his location.

-Save the whole image.

I'm using EntityFrameWork and SQL server Database

  • Dear @ZerghouniIdriss, take a look at this link: http://forums.asp.net/t/1096999.aspx?Storing+images+in+SQL+database+vs+storing+images+in+seperate+folder+and+using+URL+image+path – mostafa8026 Mar 27 '16 at 05:29
  • Both are valid. Use some thinking, then make a decision - this is a very opinionated question and depends extremely on circumstances. – TomTom Mar 27 '16 at 05:33
  • See [Microsoft's answer](http://research.microsoft.com/pubs/64525/tr-2006-45.pdf). Regarding file system solution, see also SQL Server's functionalities: [Filestream, Filetable](https://msdn.microsoft.com/en-us/library/hh403405.aspx) + [Remote Blob Storage](http://go.microsoft.com/fwlink/?LinkId=210422). – Bogdan Sahlean Mar 27 '16 at 06:50

2 Answers2

2

It depends on your application needs, Look at the answers in this post Storing Images in DB - Yea or Nay?

Storing images into database has some pros and cons

Images stored in the database do not require a different backup strategy. Images stored on filesystem do

It is easier to control access to the images if they are in a database. Idle admins can access any folder on disk. It takes a really determined admin to go snooping in a database to extract the images

On the other hand there are problems associated

Require additional code to extract and stream the images Latency may be slower than direct file access Heavier load on the database server

Community
  • 1
  • 1
Pamira
  • 129
  • 7
1

I suggest to save the image somewhere on file system and store path of that in database.

Advantages:

  1. Images will be static files and can be served directly by Web Server and also can be cached easily.
  2. DB server will not be overloaded with lot of request to fetch image data.
  3. No need of dynamic code to serve files.
  4. File system storage is less expensive then DB storage.

All over the web, most of the images are stored in filesystem.

Adnan Umer
  • 3,669
  • 2
  • 18
  • 38
  • You nicely show how little you know about SQL Server. First, consistent backups good bye, second: what about storing it IN THE DATABASE IN THE FILE SYSTEM? – TomTom Mar 27 '16 at 05:33