Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 22nd, 2004, 03:20 PM
dkb dkb is offline
Authorized User
 
Join Date: Oct 2003
Location: , , United Kingdom.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Returning an image from an ASP page

Could anyone advise me how to return an image from an ASP page?

Say for example you would like to provide an image tag with a source that links to a page:-

<img src="http://www.aServer.anAspPAge.asp?name="x.jpg">

I know it can be done in asp.net, can it be done in ASP.

Thanks.

Reply With Quote
  #2 (permalink)  
Old September 23rd, 2004, 03:18 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

If you want to read the image from your file system & write it from asp, you can do this
Code:
Response.ContentType = "image/jpg" ' "image/gif" "img/png"
Dim stream
Set stream = Server.CreateObject("ADODB.Stream")
Call stream.Open()
stream.Type = adTypeBinary
Call stream.LoadFromFile("[path to file here]")
Call Response.BinaryWrite(stream.Read())
Set stream = Nothing
n.b. you will need to reference the ado constants or substitute 1 for adTypeBinary fo this to work.

HTH,

Chris

Reply With Quote
  #3 (permalink)  
Old September 23rd, 2004, 03:41 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You may also want to add:
Code:
Response.Flush
Response.End
to the end of the code as I have known it hang sometimes on large images.

--

Joe
Reply With Quote
  #4 (permalink)  
Old September 23rd, 2004, 04:46 AM
dkb dkb is offline
Authorized User
 
Join Date: Oct 2003
Location: , , United Kingdom.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Chris,Joe,

Thanks very much, will have a go.



Reply With Quote
  #5 (permalink)  
Old February 21st, 2008, 01:20 AM
Registered User
 
Join Date: Feb 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure if this is helpful but I think you can simplify the code by using server.execute, i.e.

Code:
Response.ContentType = "image/GIF"
server.Execute("/images/shared/t.gif")
Does anyone have any comment on this alternative technique? Seems to work for me.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning current page number Larry Landis Word VBA 1 January 26th, 2007 09:23 AM
Returning Stored Procedure Results from ASP page JennaAckerson Classic ASP Basics 0 December 23rd, 2005 11:44 AM
make an image rollover that calls an asp page gavmc Classic ASP Basics 0 December 15th, 2005 12:13 PM
returning XML from ASP page amrit_82 Classic ASP Professional 4 July 6th, 2004 05:37 PM
Counting Users returning to a page they filled out bicho Classic ASP Basics 1 July 6th, 2003 03:16 PM



All times are GMT -4. The time now is 09:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.