Subject: how do I strip a URL down to the filename?
Posted By: mikehsu317 Post Date: 7/1/2005 5:06:53 PM
How do I strip the URL down to just the file name?

I have
dim dept1, filename
dept1 = Session("Dept")
filename = request.ServerVariables("URL")
filename = filename.substring(filename.lastIndexOf("//"))

I'm thinking .net and it's not working saying that i need an object on the last line.

The third line returns
/something/mypage.asp
I want to get that down to just mypage.asp

thanks
Michael Hsu

Reply By: om_prakash Reply Date: 7/3/2005 2:52:00 AM
I think there is issue with
filename = filename.substring(filename.lastIndexOf("//"))

If you are using vbscript, then above statement is not correct.

One approach can be:
filename = split(filename,"/")
Response.Write filename(uBound(filename))
In above example, you need to check for empty string and uBound as well.

Om Prakash

Go to topic 32353

Return to index page 518
Return to index page 517
Return to index page 516
Return to index page 515
Return to index page 514
Return to index page 513
Return to index page 512
Return to index page 511
Return to index page 510
Return to index page 509