|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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%> |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
thank you ngibsonau
short.... sweet.... and accurate Ben. ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Hide missing images??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|