Images in asp...

J

Jack Turner

Hi all,

Sorry if its been asked in here before but...

....how would i go about having an asp page send an image to the browser?

what i mean is instead of:
<img src="image.jpg"/>

I want:
<img src="image.asp?image=2"/>

Any idea's, pointers, url's would be appreciated, as google is firing
blanks.

Thanks in advance
 
N

Nathan Sokalski

Something like <img src="image.asp?image=2"/> would simply be using an ASP
page as the source. Instead, write a method using Sub that will take a
parameter and write the desired image. I don't know what the names of your
image files are, but if they are image1.jpg, image2.jpg, imageX.jpg, etc.,
you could write something like:

<%
Sub ImageFile(filename_suffix)
Response.Write("<img src=" & Chr(34) & "image" & filename_suffix &
".jpg" & Chr(34) & " />")
End Sub
%>

And then use the following:

<%
ImageFile "1"
ImageFile "2"
ImageFile "X"
%>

To give the following output:

<img src="image1.jpg" />
<img src="image2.jpg" />
<img src="imageX.jpg" />

You will probably want to modify this code to your desire, and maybe put it
in a loop if you have a bunch of images like image1.jpg, image2.jpg,
image3.jpg, etc. that you would like next to each other. I hope this helps.
 
J

Jack Turner

In a weird place they call a newsgroup, Nathan Sokalski woke up and
posted using
(e-mail address removed) as their email address:
|| Something like <img src="image.asp?image=2"/> would simply be using
|| an ASP page as the source.

Thats what i want, i want it so i can prevent hotlinking asp-side.

IE on the asp source it has to have a valid refering address, else it
redirects the user to an error image.
 
E

Evertjan.

Jack Turner wrote on 03 feb 2005 in
microsoft.public.inetserver.asp.general:
In a weird place they call a newsgroup, Nathan Sokalski woke up and
posted using
(e-mail address removed) as their email address:
|| Something like <img src="image.asp?image=2"/> would simply be using
|| an ASP page as the source.

Thats what i want, i want it so i can prevent hotlinking asp-side.

IE on the asp source it has to have a valid refering address, else it
redirects the user to an error image.

Stream your image:

<http://aspfaq.com/show.asp?id=2276>
 
A

Adrienne

Gazing into my crystal ball I observed "Jack Turner" <Jack@jt3k
(nospammy).co.uk> writing in @text.news.blueyonder.co.uk:
In a weird place they call a newsgroup, Nathan Sokalski woke up and
posted using
(e-mail address removed) as their email address:
|| Something like <img src="image.asp?image=2"/> would simply be using
|| an ASP page as the source.

Thats what i want, i want it so i can prevent hotlinking asp-side.

IE on the asp source it has to have a valid refering address, else it
redirects the user to an error image.

<% if request.servervariables("HTTP_HOST") = "www.example.com" then %>
<img src="yourimage.png" alt="Your image description" />
<% else %>
<img src="badimage.png" alt="Stop Thief!" />
<% end if %>
 
E

Evertjan.

Adrienne wrote on 04 feb 2005 in microsoft.public.inetserver.asp.general:
Gazing into my crystal ball I observed "Jack Turner" <Jack@jt3k
(nospammy).co.uk> writing in @text.news.blueyonder.co.uk:


<% if request.servervariables("HTTP_HOST") = "www.example.com" then %>
<img src="yourimage.png" alt="Your image description" />
<% else %>
<img src="badimage.png" alt="Stop Thief!" />
<% end if %>

This will not help you, as the path to the img is available clientside.

The only solution is to stream the img as an asp page testing for
referrer first.

<http://aspfaq.com/show.asp?id=2276>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top