Forum Moderators: open

Message Too Old, No Replies

server variable "script_name"

pulls current folder plus the script name

         

macrost

10:09 pm on Mar 25, 2004 (gmt 0)

10+ Year Member



When I use Request.ServerVariables("SCRIPT_NAME"), it will pull /html/scriptname.asp. I know this is a stupid question, but I just need the name of the file itself.
Thanks!

<added>
I know that I can use a replace on it, but that is very limiting in itself. Is there a way to use InStr or InStrRev to do this?
</added>

[edited by: macrost at 10:12 pm (utc) on Mar. 25, 2004]

bakedjake

10:12 pm on Mar 25, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Mac, I know that DOCUMENT_NAME does it on Apache, but I don't think IIS has that variable.

txbakers

10:12 pm on Mar 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you can split the string at the "/" and take the filename part.

in Javascript you can do a "lastIndexof" and then take the rightmost chars from that point.

in VB you can do a "right" command based on the inStr of the second "/"

lots of options.

bakedjake

10:24 pm on Mar 25, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



heh. Weird.

I can get it fine by doing:

<!-- #echo var=DOCUMENT_NAME -->

But response.servervariables doesn't give it to me.

macrost

10:28 pm on Mar 25, 2004 (gmt 0)

10+ Year Member



tx,
Ahh forgot about me split function. :) I'll give that a go, I'm sure it'll work. ;)

Mac