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!

FileSystemObject Check if Image exists 1

Status
Not open for further replies.

samgs

Technical User
Oct 22, 2002
6
US
I am getting the value for the image name from the SQL database. I then want to check if the image exists in the images folder, if it exists it should show the image, if the image is not there it should show a standard image, which is (noimage.gif). I have written the code as below.

set fso = Server.Createobject("Scripting.FileSystemObject")
path = "securePath & 'products/images/' & rs('imageUrl')"
'path is the path to the if fso.FileExists(path) then%>
<a href=&quot;viewItem.asp?idProduct=<%=rs(&quot;idProduct&quot;)%>&quot;><img src='<%=securePath%>products/images/<% =rs(&quot;imageUrl&quot;)%>' border=0 width=100></A>
<%else%>
<img src=&quot;<%=securePath%>products/images/imageNA.gif%>&quot; border=0 width=100>
<%end if%>

However when I run the script it always goes to else part even if the image is there. It does not show the image. If I check the properties of the image it shows as below.
I do not know why I am getting the % sign at the end. Can some help me.
 
The file system object is designed for use on a drive on the LAN to the web server. I don't think you can use it on a WAN or by using a URL.

I could be wrong, but none of my references discuss using a URL to map the FileSystemObject.

ToddWW
 
1st, try to print out your path. i suspect the file path is wrong.

2nd, the reason u get the % sign is because of this line :
<img src=&quot;<%=securePath%>products/images/imageNA.gif%>&quot; border=0 width=100>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top