Evert Jor
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("Sc ripting.Fi leSystemOb ject")
if fs.FileExists("c:\inetpub\ wwwroot\"& (rsProduct s4("ImageS rc"))&"") then
response.write ""
else
response.write" The file c:\inetpub\wwwroot\"&(rsPr oducts4("I mageSrc")) &" 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.
dim fs
set fs=Server.CreateObject("Sc
if fs.FileExists("c:\inetpub\
response.write ""
else
response.write" The file c:\inetpub\wwwroot\"&(rsPr
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Seems like you're allowing directory traversals.. use Server.MapPath(rsProducts4("ImageSrc")) instead.
ASKER
Yes, that did the trick. Thanks!