[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Need to rewrite code for checking if a file exists

Posted on 2016-10-26
3
Medium Priority
?
93 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 53

Accepted Solution

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

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

Open in new window

Regards
1
 
LVL 35

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

650 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