IS there a way I can do an If exist to determin if a graphic is displayed?

something like this;


<p align="center">

if file exist "fileone.jpg"
<img border="0" src="fileone.jpg">
if File exist "filetwo.jpg"
<img border="0" src="fileone.jpg">
</p>


What I am trying to do is post JPGs from a folder structure, the files may
or maynot be there, but I don't want to have the blank picture reference to
be displayed as if I where to just hard code the graphics in the Html!

Re: IF exist /w FSO by Anthony

Anthony
Fri May 16 01:02:03 CDT 2008

"EQNish" <EQNish@discussions.microsoft.com> wrote in message
news:59B29EC7-F4DC-4AFD-8F1E-8A5E93AAADAB@microsoft.com...
> IS there a way I can do an If exist to determin if a graphic is displayed?
>
> something like this;
>
>
> <p align="center">
>
> if file exist "fileone.jpg"
> <img border="0" src="fileone.jpg">
> if File exist "filetwo.jpg"
> <img border="0" src="fileone.jpg">
> </p>
>
>
> What I am trying to do is post JPGs from a folder structure, the files may
> or maynot be there, but I don't want to have the blank picture reference
to
> be displayed as if I where to just hard code the graphics in the Html!
>

Try this (warning air code):-

<%

Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")

Dim fileNames
fileNames= Array("fileone.jpg", "filetwo.jpg") 'Note these are URL paths

%>


<p align="center">
<%

Dim fileName
For Each fileName in fileNames
If fso.FileExists(Server.MapPath(fileName)) Then
%>
<img border="0" src="<%=fileName%>" />
<%
End If
Next
%>
</p>


--
Anthony Jones - MVP ASP/ASP.NET




Re: IF exist /w FSO by Evertjan

Evertjan
Fri May 16 12:17:47 CDT 2008

Anthony Jones wrote on 16 mei 2008 in
microsoft.public.inetserver.asp.general:

> "EQNish" <EQNish@discussions.microsoft.com> wrote in message
> news:59B29EC7-F4DC-4AFD-8F1E-8A5E93AAADAB@microsoft.com...
>> IS there a way I can do an If exist to determin if a graphic is
>> displayed?
>>
>> something like this;
>>
>>
>> <p align="center">
>>
>> if file exist "fileone.jpg"
>> <img border="0" src="fileone.jpg">
>> if File exist "filetwo.jpg"
>> <img border="0" src="fileone.jpg">
>> </p>
>>
>>
>> What I am trying to do is post JPGs from a folder structure, the
>> files may or maynot be there, but I don't want to have the blank
>> picture reference
> to
>> be displayed as if I where to just hard code the graphics in the
>> Html!
>>
>
> Try this (warning air code):-
>
> <%
>
> Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
>
> Dim fileNames
> fileNames= Array("fileone.jpg", "filetwo.jpg") 'Note these are URL
> paths
>
> %>
>
>
> <p align="center">
> <%
>
> Dim fileName
> For Each fileName in fileNames
> If fso.FileExists(Server.MapPath(fileName)) Then
> %>
> <img border="0" src="<%=fileName%>" />
> <%
> End If
> Next
> %>
> </p>

Or you can send a default I'm-sorry-image by dedicated 404.asp, having:

qstr = lcase(Request.ServerVariables("QUERY_STRING"))
if right(qstr,4)=".jpg" or right(qstr,4)=".gif" then
response.redirect "/special/404.jpg"
end if

[make sure /special/404.jpg exists]


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)