Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies

ASP how to check if image is their and download it if not

2:24 pm on Aug 6, 2008 (gmt 0)

New User

10+ Year Member

joined:Aug 1, 2008
votes: 0

Classic ASP - I don't know where else to ask ---

My idea(this is how i see it in my mind and hope it helps:
dim urltemp, filename
urltemp = "http://test.com/image.jpg"
filename = right(urltemp,/) 'this would get the image file name
if exists("images/" & filename) then
<img src="images/""" & filename & """ border=0>
{get urltemp and save it to the "images/" directory}
<img src="images/""" & filename & """ border=0>
end if

*I don't know how to get the filename or do the image download part of the code to the server.


10:32 pm on Aug 9, 2008 (gmt 0)


WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
votes: 3

I am just trying to figure out what you are trying to do.

Are you trying to download the image from a remote site to the local file system? And then reuse it on your site?

8:41 pm on Aug 11, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 27, 2003
posts: 62
votes: 0

This is how I do it (IIS6)

<%Set File = CreateObject("Scripting.FileSystemObject")
ImagePath = "d:\Web\htdocs\imgstore"
ImagePath = ImagePath & "\" & "stock_image_width237_" & RSStock("stock_image_id") & ".jpg"
If File.FileExists(ImagePath) Then %>
<a href="imgview_jpg.asp?stock_image_id=<%=RSStock("stock_image_id")%>">
<IMG alt="Loading..." border=1 SRC="\imgstore\width237\stock_image_width237_<%=RSStock("stock_image_id")%>.jpg" width="237"></a>
<%Else %>

9:27 pm on Aug 13, 2008 (gmt 0)

Full Member

10+ Year Member

joined:Jan 17, 2007
votes: 0

Ugh, I forgot just how ugly classic ASP looks.

Here's the .NET code I use to download images from another server (it's part of a thumbnail generating script):

Dim filename As String = "http://www.test.com/image.jpg"
Dim req As WebRequest = WebRequest.Create(filename)
req.Method = WebRequestMethods.File.DownloadFile

Dim resp As WebResponse = req.GetResponse
Dim respStream As Stream = resp.GetResponseStream
Dim full As System.Drawing.Image
full = System.Drawing.Image.FromStream(respStream)

Sorry, but I abandoned classic ASP a long time ago. It's a good idea to start converting your site(s) to .NET anyways.