|
From: EQNish on 15 May 2008 23:14 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!
From: Anthony Jones on 16 May 2008 02:02 "EQNish" <EQNish(a)discussions.microsoft.com> wrote in message news:59B29EC7-F4DC-4AFD-8F1E-8A5E93AAADAB(a)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
From: Evertjan. on 16 May 2008 13:17 Anthony Jones wrote on 16 mei 2008 in microsoft.public.inetserver.asp.general: > "EQNish" <EQNish(a)discussions.microsoft.com> wrote in message > news:59B29EC7-F4DC-4AFD-8F1E-8A5E93AAADAB(a)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)
|
Pages: 1 Prev: Problem getting hacked with this new SQL injection Tool. Adword71 Next: CDO.Message problems |