[Zope-dev] How to get the FULL path of an uploaded file?
Casey Duncan
c.duncan@nlada.org
Thu, 18 Oct 2001 15:01:39 -0400
On Thursday 18 October 2001 02:37 pm, Craeg K. Strong allegedly wrote:
> Does anyone know offhand how to get the FULL path of an uploaded file?
Some browsers (IE notably) supply this information. Most others do not, they
only provide the file name. It is not however, terribly useful to the server
or secure to store this information unless such data is not publically
accessible.
>
> I am using the standard HTML <input type="file"> within a form inside a
> DTML document.
>
> Inside my python method, I am getting a
> ZPublisher.HTTPRequest.FileUpload object. Fine.
>
> This stuff wraps the standard python cgi module to give you access to
> the headers and contents of the
> file. You can use a FileUpload the same way you would use a file.
>
> The problem is: the name of the FileUpload is the leaf name of the
> file, but not the entire path.
>
> Does anyone know how to get the FULL PATHNAME as listed in the input
> field in the HTML form?
>
> I believe Python is being too clever by half and by the time I get my
> grubby hands on it, the value is gone.
This is not a Python issue, many browsers simply do not provide this
information when the data is posted.
>
> The only thing I could come up with was an awful little JavaScript hack
> where I snag the value from the
> input field into another "hidden" field using OnChange/OnClick/OnBlur,
> and grab it later.
That is probably the best way I can think of. Don't feel bad though,
Javascript code is always a hack! 8^)
>
> Any suggestions would be greatly appreciated. Thanks!
>
> (Should I repost this question on a python-dev list? hmmmmm)
>
> --Craeg
/---------------------------------------------------\
Casey Duncan, Sr. Web Developer
National Legal Aid and Defender Association
c.duncan@nlada.org
\---------------------------------------------------/