473,395 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

IF exist /w FSO

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!

Jun 27 '08 #1
2 2067
"EQNish" <EQ****@discussions.microsoft.comwrote in message
news:59**********************************@microsof t.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

Jun 27 '08 #2
Anthony Jones wrote on 16 mei 2008 in
microsoft.public.inetserver.asp.general:
"EQNish" <EQ****@discussions.microsoft.comwrote in message
news:59**********************************@microsof t.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)
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: jeanfor | last post by:
I get a http 500 error on all asp pages. When turning off the friendly message box, the message is "Class does not exist". What is the fix for that? This affect all asp pages incling the default...
12
by: zhisol | last post by:
how can i check if file exist in current directory (in javascript)? -- pozdr;) zhisol
1
by: Peter | last post by:
Hi, When my program starts up, it uses MAPILogonEx to connect to the default email profile (set by user). The problem is, if the email profile no longer exist, it would give an error "The...
2
by: adam | last post by:
hello What query shoul I send to SQL serwer ( in transact SQL language ) to check does some database exist on serwer ? It similar to problem "does some table exist in database" - resolve to it...
0
by: Dirk Försterling | last post by:
Hi all, a few days ago, I upgraded from PostgreSQL 7.2.1 to 7.4, following the instructions in the INSTALL file, including dump and restore. All this worked fine without any error (message). ...
4
by: Mike | last post by:
Hi, I am looking for function in .Net library that let me know if exist any file if I specified template. Eg: I specify "*.txt" and if any file (1.txt, 2.txt, .. ) exists then I can get True...
52
by: paytam | last post by:
Hi all Can anyone tell me how can I check that a file exist or no.I mean when you use this commands FILE *fp; if(!fp) //Could not open the file doen't show why it can not open it,may be the...
1
by: sword | last post by:
This my first starting a new topic in English. I want to ask if I want to judge whether a file exists how I should do. I program with C++. Thank you.
3
by: kang jia | last post by:
hi, currently i am doing booking car online and one of the function is cancel and update booking. if the booking number users entered in is not exist. it will redirect the page stating that the...
3
by: moltendorf | last post by:
I copied the files from my "test" database on my old server (MySQL was not running) to my new server ("./mysql/data/test" folder), and after starting the server, SHOW TABLES; shows all of the tables...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.