Hi all, I am trying to upload an image file from a form to an External Method so that it can be loaded as a blob into an Oracle database. I am having difficulty getting the file uploaded. Here is the form: <form action="execute_loadblob" method="post" enctype="multipart/form-data"> <p>Locate file to upload:</p> <input type="file" name="image" size="16"> <input type="submit" name="submit" value="Submit Entry"> </form> ======================================================================= The external method is called from a DTML method called "execute_loadblob" which contains the call: <dtml-var expr="writeBlob(image)"> The external method is: import sys,os,string,DCOracle2 as dco def main(image): ... do something here with image, doesn't matter what ... return "Something was done" ============================================================= The gist of the error received, is that image is a " ZPublisher.HTTPRequest.FileUpload instance at 1046b04" instead of being something I can acutally manipulate. Why is this and how do I access either the file or the URL pointing to the file? TIA, Mark Evans
Mark Evans wrote:
Hi all,
I am trying to upload an image file from a form to an External Method so that it can be loaded as a blob into an Oracle database. I am having difficulty getting the file uploaded. ... The gist of the error received, is that image is a " ZPublisher.HTTPRequest.FileUpload instance at 1046b04" instead of being something I can acutally manipulate. Why is this and how do I access either the file or the URL pointing to the file?
Please read the source... Zope/lib/python/ZPublisher/HTTPRequest.py defines the FileUpload-Class: class FileUpload: '''\ File upload objects 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. ''' It's all there you need... -mj -- Universität Bielefeld - Zentrum für Lehrerbildung http://www.zfl.uni-bielefeld.de tlph://+49.0521.106.4234
Mark Evans wrote at 2003-3-10 11:51 -0800:
.... I am trying to upload an image file from a form to an External Method .... .... The external method is called from a DTML method called "execute_loadblob" which contains the call:
<dtml-var expr="writeBlob(image)">
The external method is:
import sys,os,string,DCOracle2 as dco def main(image): ... do something here with image, doesn't matter what ... return "Something was done"
=============================================================
The gist of the error received, is that image is a " ZPublisher.HTTPRequest.FileUpload instance at 1046b04" instead of being something I can acutally manipulate. Why is this and how do I access either the file or the URL pointing to the file?
This error message does not seem to fit to your description. Instead, it looks as if the uploaded image were returned as result of the web request. This should never happen (Web request results should be elementary data types). When ZPublisher is confronted with an (non-elementary) object as response to a request it raises an error. Dieter
participants (3)
-
Dieter Maurer -
Maik Jablonski -
Mark Evans