I'm not sure quite what you mean.
Do you (a) just want the trailing filename, or do you want the trailing
filename relative to some arbitrary point in (b) the local file
structure, or (c) an http request url?
The reason I ask is twofold:
1) You don't clarify whether you expect filenames in sub directories to
include path information or not. I could assume you do, I could assume
you don't, instead I choose to confirm your expectation in such
circumstances.
2) If you do expect path information, then although for "
http://host/
file" where "file" is at "<docroot>/file", "file" will generally be the
same for a, b and c, and in many webservers this is probably the case,
there are probably also many webservers where due to directory aliasing
in the server, or the use of links (is shortcuts what Ms calls them?) in
the file system and directory structure, or for some other reason, the
filename, the "path+file" url components and the actual filesystem
location of the file (whether absolute or relative to some arbitrary
point) may bear no obvious relationship whatsoever to each other.
Hence, although I see many answers in this thread that address a flat
single directory situation, I'm not 100% sure, partly because I'm not
sure what you actually expect in such cases, that they will give the
answers you expect in every situation in which you might conceivably
deploy them.
Rgds
Denis McMahon