Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting if image url is valid

Status
Not open for further replies.

UncleCake

Technical User
Feb 4, 2002
355
US
Hi,

Is there a way that I can detect if a image url is valid? I want to display a missing image place holder if the image is missing.

-Uncle Cake
 
You can use this to check for an instance of that image file::
public function isValidImage(fileName)
dim fsoObj
set fsoObj = server.createobject("scripting.filesystemobject")
if fsoObj.FileExists(server.mappath("\images") & "\" & fileName) then
isValidImage = true
else
isValidImage = false
end if
if isObject(fsoObj) then set fsoObj = nothing
end function

Then you can call it like so::
if isValidImage("myimage.gif") then
response.write &quot;<img src=&quot;xxx.gif&quot;>
else
response.write &quot;no image&quot;
end if

Megalene
If you crap it will stink!
 
Thanks, would that have to go in a dll or could it just go on the asp page?

-Uncle Cake
 
plug that right into your asp page. Megalene
If you crap it will stink!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top