Results 1 to 6 of 6

Thread: Getting Asp File name

  1. #1

    Thread Starter
    Hyperactive Member Hampster's Avatar
    Join Date
    Feb 2001
    Location
    On my hamster wheel.
    Posts
    374

    Getting Asp File name

    I'm working on a simple asp file, and I don't always know what the file name will be. (If the user decides to change it...) Is there a way I can return the asp's file name? (MyFile.asp) or have the asp file post to its self without knowing the file name?

    Thanks if you can help me

  2. #2
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Perphaps u need this:

    Code:
    <%
    mFileName = Request.ServerVariables("SCRIPT_NAME")
    %>
    Bye


  3. #3
    Member FrogBoy666's Avatar
    Join Date
    Aug 2000
    Location
    Columbia, SC
    Posts
    34

    Smile Or...

    In my constant quest to make things more difficult for myself, I usually take that a little further. So, if you want to return only the file name, you can do the following:

    Code:
    Function GetThisFileName()
    
        Dim pstrNameWithPath
        Dim pstrJustFileName
        Dim pintSlashLoc
    
        pstrNameWithPath = Request.ServerVariables("SCRIPT_NAME")
        pintSlashLoc = InStrRev(pstrNameWithPath,"/")
      
        If InStr(1,pstrNameWithPath,"/") <> 0 Then
            pstrJustFileName = Right(pstrNameWithPath,Len(pstrNameWithPath) - pintSlashLoc)
        End If
    
        GetThisFileName = LCase(pstrJustFileName)
    
    End Function
    And, of course, you just put a <%= GetThisFileName %> wherever you want the filename to appear.

  4. #4

    Thread Starter
    Hyperactive Member Hampster's Avatar
    Join Date
    Feb 2001
    Location
    On my hamster wheel.
    Posts
    374

    Talking

    Thanks for your help

    I also learned that if you have the post value to "" it posts to its self

  5. #5
    Member FrogBoy666's Avatar
    Join Date
    Aug 2000
    Location
    Columbia, SC
    Posts
    34
    Yeah, but where's the fun in that?!

  6. #6
    Member FrogBoy666's Avatar
    Join Date
    Aug 2000
    Location
    Columbia, SC
    Posts
    34

    Angry Forgot about Netscape...

    I also learned that if you have the post value to "" it posts to its self
    If you try this with Netscape, it returns the directory that holds the file, instead of the file itself... so you would still need to use Request.ServerVariables("SCRIPT_NAME") to get the correct results.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width