-1

actually i m devloping a web application that provides facility to users upload the image as we see in orkut and facebook through a form and a upload button.but the actually problem I am facing is :

1.should i store the image in database using Large data objects ie BLOB and the problem arises of retrieving it back from the database and then displaying it on the form.

2.sholud i store the absolute path of the the image in database and provide it to the source tag of the image in the html form.

sandeep manglani
  • 77
  • 1
  • 2
  • 6
  • Dupe. See: http://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay – gpmcadam Mar 19 '10 at 08:01
  • Note serving user files is bit tricky from a security perspective. In order to prevent same-origin violations/XSS attacks, it is usual to put them on a different domain with different IP addresses. I believe Facebook re-encodes every image to try to ensure that there are no image handling exploits and no hidden code. – Tom Hawtin - tackline Mar 19 '10 at 14:57

2 Answers2

2

I would advise against saving images in the database. This usually gives poor performance since files work better from the file system, data in the database etc.

It will also be harder to scale the database when the number of images grows than to just store them in a file system.

I would store the path to the file in the database, you can store a relative path and then have a constant in the web application to the root directory containing the images.

Neal Donnan
  • 1,733
  • 1
  • 13
  • 18
0

This will be of use to you. The Facebook engineers had a nice talk concerning Efficient storage of Billions of Photos

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228