|
-
Mar 19th, 2002, 10:11 PM
#1
Thread Starter
Hyperactive Member
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
-
Mar 20th, 2002, 02:45 AM
#2
PowerPoster
hi
Perphaps u need this:
Code:
<%
mFileName = Request.ServerVariables("SCRIPT_NAME")
%>
Bye
-
Mar 21st, 2002, 10:42 AM
#3
Member
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.
-
Mar 21st, 2002, 10:45 AM
#4
Thread Starter
Hyperactive Member
-
Mar 22nd, 2002, 03:09 PM
#5
Member
Yeah, but where's the fun in that?!
-
Mar 27th, 2002, 12:19 PM
#6
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|