The problem was cleaning filenames from file uploads in browers that pass the entire local path to the server. Stupid browsers.
os.path.basename seems to only work in the context of the path as given on the local system: ie. when used on Unix, it does not fix up Windows filenames. At the very least I can't get it to work on my Mac OS X box.
Terry's suggestion again neglects non-Windows paths where forward slash or semicolon can be the separator.
I'm left thinking my algorithm - find the last slash, backslash, or semicolon, and go to the end - is the most universal approach.
Probably. There are catches: a colon can be part of a valid filename in Unix. What else beside IE is broken in this particular stupid way? (I've not heard of other browsers doing this.) If it's just IE you could just correct for Windows paths. If IE Mac is included, well, you can't break on colons unless you're sure it's not a Mac path. Unless it translates it into a Windows path, which wouldn't surprise me in the least. If you really want full coverage, I think you'll have to figure out what a string is (Mac path, Unix path, Win path, just a filename) and then parse it using platform rules. How exactly to do this I can't say... --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."