Search code examples
asp-classic

Does File Exist? ASP Classic


Here is a simple example from W3 Schools:

dim fs

strFilePath = "http://lanswinweb1/assembly/scrollingimages/images/" & Session("Num") & ".jpg"
'strFilePath = "P:\Assembly\Team Performance Boards\LDT Scrolling Monitor\" & Session("Num") & ".jpg"
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists(strFilePath) then
  Session("Num") = Session("Num") + 1
  response.write("File: " & strFilePath & " exists!")
else
  response.write("File: " & strFilePath & " does not exist!")
end if
set fs=nothing

This is giving me:

enter image description here

Yet when I go to that link in the web address, it works: enter image description here

So, what is it that I am missing or doing wrong?


Solution

  • Thank you @Lankymart for the help!

    strFilePath = Server.MapPath(".") & "\images\1.jpg"
    

    Solves it!