Solved

Need to rewrite code for checking if a file exists

Posted on 2016-10-26
3
81 Views
Last Modified: 2016-10-26
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.
0
Comment
Question by:Evert Jor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41860228
HI,

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

Open in new window

Regards
1
 
LVL 34

Expert Comment

by:ste5an
ID: 41860284
Seems like you're allowing directory traversals.. use Server.MapPath(rsProducts4("ImageSrc")) instead.
1
 

Author Closing Comment

by:Evert Jor
ID: 41860501
Yes, that did the trick. Thanks!
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question