Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > IF exist /w FSO

Reply
Thread Tools

IF exist /w FSO

 
 
EQNish
Guest
Posts: n/a
 
      05-16-2008
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!

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      05-16-2008
"EQNish" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      05-16-2008
Anthony Jones wrote on 16 mei 2008 in
microsoft.public.inetserver.asp.general:

> "EQNish" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP FSO File Name Problem KEN ASP .Net 1 07-26-2007 06:55 AM
Does my object exist? So why its HWND doesn't exist? That's a question... (CMonthCalCtrl control) LT C++ 7 07-25-2004 07:08 PM
Can the Favourites Sidebar (IE, Opera, etc.) be addressed selectively (exist or non-exist)? Markus Mohr Javascript 7 11-28-2003 12:20 AM
In Schema, how to say "If one element exist, another element must exist"? Y.S. XML 3 09-17-2003 02:51 PM
Help:Why can't I use namespace System.Web? It is said that this namespace doesn't exist. But it should exist. ASP .Net 1 07-29-2003 04:31 PM



Advertisments