Announcement

Collapse
No announcement yet.

Way to get the name of the current file?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Way to get the name of the current file?

    Is there any automatic way in ASP to get the file name? I know you can use ServerVariables("SCRIPT_NAME"), but that's not one of the valid server variables availiable. The "FILE_PATH" gives the path on the computer (ie, C:\program files...) but I want it so that it says what the name of the current file is. I suppose I could just set a variable and type it in, but then if I copy that code over to another page and I forget to do that it won't work.

    ---
    Todd
    My HomeSeer - My Website

    #2
    This will return the file name only:

    <pre class="ip-ubbcode-code-pre">Mid(Request.ServerVariables("PATH_INFO"), InstrRev(Request.ServerVariables("PATH_INFO"), "\") + 1)</pre>

    Comment


      #3
      I figured there had to be some string functions, but wasn't familiar with how ASP does it, thanks

      ---
      Todd
      My HomeSeer - My Website

      Comment


        #4
        Code snippet to replace footer.asp with if anyone is interested.

        &lt;%

        'Create footer
        Response.Write CustomFooter()

        FN = Mid(Request.ServerVariables("PATH_INFO"), InstrRev(Request.ServerVariables("PATH_INFO"), "\") + 1)
        Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
        Set oFile = oFSO.GetFile(hs.GetAppPath & "\html\" & FN)
        dMod = oFile.DateLastModified
        Set oFSO = Nothing
        Set oFile = Nothing
        Response.Write "Copyright &copy 2002 - huggy_d1. All Rights Reserved.&lt;br&gt;"
        Response.Write "Last modified: " & dMod & "&lt;br&gt;"
        Response.Write "&lt;a href='mailto:hugginsd@nesbeonline.com?subject=" & FN & "'&gt;huggy_d1&lt;/a&gt;"

        %&gt;

        Look at http://guest:guest@www.huggy-d1.d2g.com/daily.asp to see it in action, and you should be able to pick most any link and it dynamically update the filename, and the date. It's most cool. I've been trying to figure out how to do this for a while.

        huggy(d1)
        huggy_d1

        Automating made easy

        Comment

        Working...
        X