[mod_python] uploaded file names

Nick nick at dd.revealed.net
Thu Jun 3 11:20:26 EDT 2004


Daniel J. Popowich wrote:

> My solution, which I fear may be braindead, is to do this to all
> incoming filenames:
> 
>   filename = os.path.basename(filename.replace('\\', '/'))

You may want to test the user agent first for IE before replacing the \ 
wholesale, but in general I don't think people put backslashes in filenames. 
    Personally, I do:

try:
     filename[filename.rindex('\\') + 1:]
except ValueError:
     pass

Nick


More information about the Mod_python mailing list