Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hi Frds,
I am saving my image in sql server 2005 as byte(datatype as Image),While downloading i need to know the extension of the image as like .jpg or .gif
Posted
Comments
Raje_ 14-Aug-12 6:05am    
Why don't you store image name in separate column, then it will be easy to retrieve.

1 solution

VB
WHEN LEFT(convert(varbinary(8), IDOC),2)=0x424D THEN 'BMP'
 WHEN LEFT(convert(varbinary(8), IDOC),2)=0xFFD8 THEN 'JPG'
 WHEN LEFT(convert(varbinary(8), IDOC),2)=0x4749 THEN 'GIF'
WHEN LEFT(convert(varbinary(8), IDOC),2)=0x4920 THEN 'TIF' 

Check this.

http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/24db1dc1-f12b-44b1-8ff3-6bc287a26791[^]

and this.

http://www.garykessler.net/library/file_sigs.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900