Need to rewrite code for checking if a file exists

I have this script which determines if the file exists:

dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists("c:\inetpub\wwwroot\"&(rsProducts4("ImageSrc"))&"") then
  response.write ""
else
  response.write" The file c:\inetpub\wwwroot\"&(rsProducts4("ImageSrc"))&" does not exist."
end if
set fs=nothing

My problem is that the database field (rsProducts4("ImageSrc")) has the format images/somefile.jpg
The problem is the slash. I need to change the script where the fs.FileExists evaluation is performed as to interpret the "/" as "\" as I cannot change it in the db. Any adea on how to rewrite this?

Thanks in advance.
Evert JorDVM/ResearcherAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Rgonzo1971Connect With a Mentor Commented:
HI,

pls try
 if fs.FileExists("c:\inetpub\wwwroot\" & Replace((rsProducts4("ImageSrc")),"/","\") &"") then

Open in new window

Regards
1
 
ste5anSenior DeveloperCommented:
Seems like you're allowing directory traversals.. use Server.MapPath(rsProducts4("ImageSrc")) instead.
1
 
Evert JorDVM/ResearcherAuthor Commented:
Yes, that did the trick. Thanks!
0
All Courses

From novice to tech pro — start learning today.