0

Can someone explain me how to store images on a server and then inserting the url's in the database.

All I find on the internet are discussions of which one is better - storing the url or the image itself as a BLOB. I have made it to store them as BLOB, but I don't think it is a good idea and want to store them on the server and just link them in the database.

I am using asp.net web application and have a mssql database. The language is c#.

Apostrofix
  • 2,140
  • 8
  • 44
  • 71
  • 1
    If you have a specific programming question, we are happy to help. If you want a tutorial - google for one - that's not what Stack Overflow is about. – Oded Dec 03 '12 at 11:50
  • Do you want to save the picture to the database? you can dynamically load in the links and filename from the database and the server will pull in the image using a standard – CR41G14 Dec 03 '12 at 11:50
  • @Oded, I tried google and all I find are tutorials about storing the images in the database. Then I guess you are right, so instead, I can ask how to store images on the server and link them to the database? – Apostrofix Dec 03 '12 at 11:55
  • @CR41G14 no, I want to store them on the server. The database should just contain the information about the picture - like the url, picture name and so on.. – Apostrofix Dec 03 '12 at 11:55
  • Sure, you can ask that. But you will need to explain exactly what you tried, where you are stuck and post the code you have tried. – Oded Dec 03 '12 at 11:57

2 Answers2

1

You can have a look at this article explaining Storing Uploaded Files in a Database or in the File System with ASP.NET 2.0 along with advantages and disadvantages of each technique.

Also found a useful link that might help you in this regard: Storing Images in DB - Yea or Nay?

Community
  • 1
  • 1
Furqan Safdar
  • 16,260
  • 13
  • 59
  • 93
1

You must have directory at your server like:

~/Uploads/Photos/

And in database you can have table:

Images { ImageId, PathOriginal, PathMediumSize, Thumb }

And data would be like:

/Uploads/Photos/myImageNameOriginal.png

When you wan't to display it get it's name from database and load on page from Uploads directory.

1110
  • 7,829
  • 55
  • 176
  • 334