SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 23rd, 2003, 09:58 PM
cozmic cozmic is offline
MySQL Newbie
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 9 cozmic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Hide missing images???

Is there a way I can test if an image file exists before displaying it?

I have a database that has an image field in it that users enter a filename into. Is there a way for me to check using an "if" statement that the file is actually on the drive before displaying it? ie:

<%okimage=(rsFile.Fields.Item("image").Value)
If okimage='actually on the drive' then%>
<img src='(rsFile.Fields.Item("image").Value)'>
<%else%>
<img src='noimage.jpg'>
<%end if%>

Reply With Quote
  #2  
Old March 23rd, 2003, 10:30 PM
ngibsonau ngibsonau is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 138 ngibsonau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Code:
<%
Dim objFs
Set objFs = Server.CreateObject("Scripting.FileSystemObject")

IF objFs.FileExists(Server.Mappath(rsFile.Fields.Item("image").Value) ) Then
%>
<img src='(rsFile.Fields.Item("image").Value)'>
<%else%>
<img src='noimage.jpg'>
<%
end if
set objFs = Nothing
%>
__________________
--

ngibsonau

Reply With Quote
  #3  
Old March 24th, 2003, 10:17 PM
cozmic cozmic is offline
MySQL Newbie
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Melbourne, Australia
Posts: 9 cozmic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thank you ngibsonau

short.... sweet.... and accurate

Ben.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Hide missing images???


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway