Janusz Zamecki wrote at 2006-1-28 10:30 +0100:
>Hi, after googling and RTFM I have no other option but ask you for help.
>I have the following DTML document:
><form action=3D"checkTheFile" method=3D"post" enctype=3D"multipart/form-d=
>Select the file:
><input type=3D"file" name=3D"the_file">
><input type=3D"submit" name=3D"go" value=3D"Next >>">
>And here is the checkTheFile python script:
>## Script (Python) "checkTheFile"
># Import a standard function, and get the HTML request and response objec=
>from Products.PythonScripts.standard import html_quote
>request =3D container.REQUEST
>RESPONSE =3D request.RESPONS
># the next line does'n work:
>I need to temporary save uploaded file then I have to validate it. But
>I've received the following error message:
>Error Type: AttributeError
>Error Value: read
Whenever you get an "Error", you should look at the traceback (to
be found in your "error_log" in the Zope "Root Folder").
It tells you where the error occurred.
The code you show above should not result in an "AttributeError: read".
However, it has some other problems:
* "manage_addFile" has read the uploaded file; after the call,
it is positioned at its end.
Your "read" will therefore always return ''.
You should call a "seek(0)" before you try to read the file again.
* Your code is less well readable than possible.
This could be improved by a definition
"file = request.form['the_file']" and than using "file"
rathen than "request.form['the_file']" over and over again.
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -