[Zope] stupid file upload question

Dieter Maurer dieter@handshake.de
Thu, 14 Dec 2000 23:57:47 +0100 (CET)


Joh Johannsen writes:
 > What sort of object is this "REQUEST.form['attached_file']"?   Is there some
 > way to find out this sort of thing when you have a Python object?  (I'm new
 > to Python)
It is a "ZPublisher.HTTPRequest.FileUpload" object.
From its (source) documentation:

    File upload objects are used to represent file-uploaded data.

    File upload objects can be used just like files.

    In addition, they have a 'headers' attribute that is a dictionary
    containing the file-upload headers, and a 'filename' attribute
    containing the name of the uploaded file.

 > Is that even the place to look to get the name of the file on the server
 > after it is uploaded?
You should not rely on the fact that the data is stored somewhere
on the server.

 > That's why I mentioned the quote from that How-To (which the above is
 > basically a copy of):  "In you python external method you can now reference
 > REQUEST.form['attached_file'] as a normal file. You can perform things such
 > as read() on the object. "
"REQUEST.form['attached_file']" should be a "FileUpload" object
and as such have a "read" method (beside many others).

Thus, "REQUEST.form['attached_file'].read()" should return the
file content.

In an earlier message, you said, it did not.
What happened?



Dieter