Forums

ASP

This topic is locked

If Image Exists

Posted 13 Nov 2003 15:02:32
1
has voted
13 Nov 2003 15:02:32 Matt Jukes posted:
Hi,

I guess this is simple really. I have a DB and each entry has an image. The Images are named xxx.jpg where xxx is the autonumber ID of each db entry.
so the first image is 1.jpg, 2.jpg and so on. I have been trying to write some code that if the image for the entry does not exist then a default image would be displayed. I see alot of fileExist commands but they all seem to be for uploading and this is only linked to a basic search/results page, so I'm a little lost.

Any Ideas? Any help would be great but no worries<img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Thanks

Replies

Replied 15 Nov 2003 21:26:04
15 Nov 2003 21:26:04 Phil Shevlin replied:
Not sure if its the most elegant way, but I do this:

<pre id=code><font face=courier size=2 id=code>&lt;img src="photos/&lt;% -- YOUR ASP CODE -- %&gt;.jpg" onError="this.src='photos/nophoto.jpg'"&gt; </font id=code></pre id=code>

For a brief second you see the image container, then the nophoto.jpg loads

Edited by - wdglide on 15 Nov 2003 21:26:48

Reply to this topic