User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 392,371 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,668 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting

Display image from a database get me ascii codes

Join Date: Jul 2005
Location: india
Posts: 143
Reputation: katarey is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 15
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Solution Re: Display image from a database get me ascii codes

  #4  
Nov 2nd, 2006
Hi Again,

Yes I did test that code and its working

Well have look at these

This file

1.) img.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
database = Server.MapPath("DATABASE.mdb")

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open database

    SQL = "SELECT * FROM Files WHERE FileID = 3" 
    Set Rs = conn.Execute(SQL)
    Response.BinaryWrite Rs("BinaryData").GetChunk(Rs("BinaryData").ActualSize)
        
%>



2.) imageDis.asp

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>For Help</title>
</head>
<body>
<img src="img.asp" />
</body>
</html>

3.) img1.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
database = Server.MapPath("DATABASE.mdb")

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open database

Dim SQL
Dim FileID

FileID = 4

SQL = "SELECT * FROM Files WHERE FileID = " & FileID

Set Rs = conn.Execute(SQL)
If Not Rs.EOF Then

  Response.AddHeader "content-disposition", "inline; filename=" & oRs("FileName")
  Response.AddHeader "content-length", Rs("BinaryData").ActualSize
  Response.ContentType = Rs("ContentType")
    
  Response.BinaryWrite Rs("BinaryData")
    
Else

  Response.Write("File could not be found")
    
End If        
%>

Examples:

This file will give output in ASCII codes
1.) http://www.katarey.com/forhelp/img.asp

And this file will show the image,
2.) http://www.katarey.com/forhelp/imageDis.asp

I hope This file that you want!
3.) http://www.katarey.com/forhelp/img1.asp


I hope this will helpful for you, please feel free to ask question if any

Thanks
Regards,
Rahul Dev
Last edited by tgreer : Nov 3rd, 2006 at 3:29 pm. Reason: Removed unnecessary quote block.
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote  
All times are GMT -4. The time now is 12:55 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC