Link to home
Start Free TrialLog in
Avatar of Evert Jor
Evert JorFlag for Norway

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Seems like you're allowing directory traversals.. use Server.MapPath(rsProducts4("ImageSrc")) instead.
Avatar of Evert Jor

ASKER

Yes, that did the trick. Thanks!