Results 1 to 12 of 12

Thread: ASP + <IMG> help

  1. #1
    LWA
    LWA is offline
    Senior Member
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,171
    Thanks
    134
    Thanked
    57 times in 41 posts

    ASP + <IMG> help

    Hey all,
    I am developing an application in asp that displays details of a user along with a photograph. However I am encountering problems.

    The application consists of two pages:

    1. Retrieves the image and displays it
    2. Displays the users details and should display the image brought back by page 1

    Page 2 uses the img tag as follows:
    <img src="photo.asp?rec_idx=2345">

    As the <img> tag expects an image, not a webpage, this code does not work.

    One idea I had was to make page 1 return the actual image code rather a web page with an image embedded within it. The only problem is, I am not sure how to do this in asp

    Does anyone have any ideas for a workaround?

    Thanks in advance,
    Leon

  2. #2
    Does he need a reason? Funkstar's Avatar
    Join Date
    Aug 2005
    Location
    Aberdeen
    Posts
    19,874
    Thanks
    630
    Thanked
    965 times in 816 posts
    • Funkstar's system
      • Motherboard:
      • Gigabyte EG45M-DS2H
      • CPU:
      • Intel Core2Quad Q9550 (2.83GHz)
      • Memory:
      • 8GB OCZ PC2-6400C5 800MHz Quad Channel
      • Storage:
      • 650GB Western Digital Caviar Blue
      • Graphics card(s):
      • 512MB ATI Radeon HD4550
      • PSU:
      • Antec 350W 80+ Efficient PSU
      • Case:
      • Antec NSK1480 Slim Mini Desktop Case
      • Operating System:
      • Vista Ultimate 64bit
      • Monitor(s):
      • Dell 2407 + 2408 monitors
      • Internet:
      • Zen 8mb
    Is there only one image per user?

    Say the user ID is 1337, then when the image is uploaded it is saves to, say http://server.domain/users/1337.jpg

    then when you are displaying the image you have somethig like

    response.write "<img src=""/users/" & userID & ".jpg"">"

    does this help?

    It should be possible to use page.asp and a query string, but you will need to use IO streams and send the binary data and the right mime type to the browser. i think the idea above is easier and has the advantage of putting less load on a server. But is also less flexible.

  3. #3
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    Quote Originally Posted by Big Leon
    Hey all,
    I am developing an application in asp that displays details of a user along with a photograph. However I am encountering problems.

    The application consists of two pages:

    1. Retrieves the image and displays it
    2. Displays the users details and should display the image brought back by page 1

    Page 2 uses the img tag as follows:
    <img src="photo.asp?rec_idx=2345">

    As the <img> tag expects an image, not a webpage, this code does not work.

    One idea I had was to make page 1 return the actual image code rather a web page with an image embedded within it. The only problem is, I am not sure how to do this in asp

    Does anyone have any ideas for a workaround?

    Thanks in advance,
    Leon
    Ahh, you need to use some asp code that will generate an image with the right parameters, I did find a snippet a while ago, I'll see if I can dig it up again
    (\__/)
    (='.'=)
    (")_(")

  4. #4
    LWA
    LWA is offline
    Senior Member
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,171
    Thanks
    134
    Thanked
    57 times in 41 posts
    Superstar thanks Stoo

  5. #5
    Gaarrrrr! Dav0s's Avatar
    Join Date
    Aug 2005
    Location
    Bristol
    Posts
    1,442
    Thanks
    1
    Thanked
    3 times in 3 posts
    is there the equivelant of the php include function?

    so u can just include the url of the webpage with image?

  6. #6
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    Response.BinaryWrite is the puppy

    http://support.persits.com/show.asp?code=PS01050249

    Last edited by Stoo; 01-02-2006 at 08:32 PM.
    (\__/)
    (='.'=)
    (")_(")

  7. #7
    LWA
    LWA is offline
    Senior Member
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,171
    Thanks
    134
    Thanked
    57 times in 41 posts
    Thanks Stoo.

    That example is writing out images from a database, in there some way I can do the same thing from a image file stored on a virtual directory? e.g. (Sudo code)

    ImageFileHandle image = "111.111.11.1\images\image.jpg"
    Response.ContentType = "image/jpeg"
    Response.BinaryWrite image

    Thanks again to anyone who can help

  8. #8
    LWA
    LWA is offline
    Senior Member
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,171
    Thanks
    134
    Thanked
    57 times in 41 posts
    Just for info guys here is the solution I came up with (with help from you all):

    Code:
    Response.Buffer = True
    Dim objXMLHTTP, xml
    Set xml = Server.CreateObject("Microsoft.XMLHTTP")
    	
    xml.Open "GET", <full_path_to_jpg_file_on_virtual_directory>, False
    xml.Send
    	
    ' Specify the content type to tell the browser what to do:
    Response.ContentType = "image/jpeg"
    
    ' Binarywrite the bytes to the browser
    Response.BinaryWrite xml.responseBody
    
    Set xml = Nothing

  9. #9
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    shweet
    (\__/)
    (='.'=)
    (")_(")

  10. #10
    Gaarrrrr! Dav0s's Avatar
    Join Date
    Aug 2005
    Location
    Bristol
    Posts
    1,442
    Thanks
    1
    Thanked
    3 times in 3 posts
    can u translate what you did lol, i dont speak ASP, although i might learn soon

  11. #11
    Sublime HEXUS.net
    Join Date
    Jul 2003
    Location
    The Void.. Floating
    Posts
    11,819
    Thanks
    213
    Thanked
    233 times in 160 posts
    • Stoo's system
      • Motherboard:
      • Mac Pro
      • CPU:
      • 2*Xeon 5450 @ 2.8GHz, 12MB Cache
      • Memory:
      • 32GB 1600MHz FBDIMM
      • Storage:
      • ~ 2.5TB + 4TB external array
      • Graphics card(s):
      • ATI Radeon HD 4870
      • Case:
      • Mac Pro
      • Operating System:
      • OS X 10.7
      • Monitor(s):
      • 24" Samsung 244T Black
      • Internet:
      • Zen Max Pro
    He's storing the image as an xml object, then getting the binarywrite function to squirt it out on the page.

    *Nice* bit of code
    (\__/)
    (='.'=)
    (")_(")

  12. #12
    LWA
    LWA is offline
    Senior Member
    Join Date
    Jul 2003
    Location
    London
    Posts
    2,171
    Thanks
    134
    Thanked
    57 times in 41 posts
    Quote Originally Posted by Stoo
    He's storing the image as an xml object, then getting the binarywrite function to squirt it out on the page.

    *Nice* bit of code
    Glad you like it dude, was pleased with the result

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 18-03-2005, 05:03 PM
  2. ASP Help required
    By TomWilko in forum Software
    Replies: 1
    Last Post: 27-10-2004, 02:36 PM
  3. Learning ASP
    By TomWilko in forum Software
    Replies: 9
    Last Post: 02-10-2004, 04:28 PM
  4. Asp
    By Angus in forum Networking and Broadband
    Replies: 1
    Last Post: 03-12-2003, 09:55 PM
  5. Asp Q?
    By joshwa in forum Software
    Replies: 6
    Last Post: 28-08-2003, 12:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •