0

I have a situation where image is currently saved on IIS Server and displayed..

Currently this HTML fragment is saved into the SQL Server database:

<img class='img-responsive' src='../resources/files/70382f46-a254-49c2-b296-9c10b2d6d152.jpg'  width='871' height='503'/>

This expects that the image exists on IIS server.

Now I want to save the image itself in SQL Server.

Is there any way I can save something like

<img class='img-responsive' src="Actual Image"  width='871' height='503'/>

If so what should be the datatype in SQL Server be, any example or links?

Thanks JM

J MR
  • 11
  • 1
  • 1
    The datatype should be varbinary(max). Surely you can look at google and find thousands and thousands of examples and/or tutorials. Sadly, this is off topic as you asking for somebody to point you to a tutorial. – Sean Lange Jun 10 '16 at 19:11

1 Answers1

0

you can go with either of these ways :

  • save in database as binary (varbinary or so ) and convert it to hex value to show in your html page like this :

    img src="data:image/png;base64,iVBrkJggg==" alt="Base 64 encoded!"

read this : (Converting from hex string to varbinary and vice versa)

you may take a look this article as well : Storing Images in DB - Yea or Nay?

Community
  • 1
  • 1
eshirvana
  • 23,227
  • 3
  • 22
  • 38