Here's the external method I wrote to do what you want: import string, os def getMimeType(self,file): __allow_access_to_unprotected_subobjects__=1 contentHeader=file.headers.headers[1] mimeType=string.split(contentHeader, ': ')[1] return mimeType def uploadFileName(self,client_name): """ Convert the file path supplied by the browser into a UNIX file name. We don't use any of the path except the basename, i.e. the file name itself. """ # if client_name has any \ in it, it's probably a Windows-style name our_name=string.replace(client_name, "\\", "/") base_name=os.path.basename(our_name) t=string.maketrans(' \'"','___') base_name=string.translate(base_name,t) return base_name -- Loren
-----Original Message----- From: Laurie Nason [mailto:laurien@tiger.3dem.bioch.bcm.tmc.edu] Sent: Friday, June 29, 2001 14:00 To: Chris Withers; Loren Stafford; Andrei Belitski; zope@zope.org Subject: RE: [Zope] extraction of complete filepath of a <input type=file> object
I have the opposite problem - I would like windoze to give me only the file name - am I going to have to parse the complete path to strip out the \'s?
Laurie
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Chris Withers Sent: Friday, June 01, 2001 2:06 PM To: Loren Stafford; Andrei Belitski; zope@zope.org Subject: Re: [Zope] extraction of complete filepath of a <input type=file> object
I thought REQUEST['my_file'].filename gave you the entire path. Are you sure it doesn't.
Only on Windoze, on Linux you only get the filename, which is more secure IMHO.
Why do you want the complete file path anyway?
cheers,
Chris
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )