forward FileUpload objects through methods
Hi, I've got a weird thing here. I have a function A in a product class that adds a file to the class instance via a HTTP-FileUpload. This function can be called via a form action directly, but I have some pages where the form action needs to be a different method B (of the same class) and also the names for the form fields have to be different. What I do then in the function B is create a dictionary prop and for all FileUpload objects from the form I create an entry in the dictionary with the apropriate name (that is used in function A) and afterwards I execute function A with prop as parameter. But if I return the props from function A I get a "string" for the FileUpload entrys not a FileUpload Instance! Is this known, is there a workaround? Andreas PS: To Illustrate this: class B: function A(self, REQUEST): f = REQUEST['file1'] if not f.filename in folder.objectIds(): folder.manage_addProduct['OFSP'].manage_addFile(id='',title='',file=f) [.. more files to add] function B(self, REQUEST): prop = {} prop['file1'] = REQUEST['file1fol'] self.A(prop) -- A vivid and creative mind characterizes you.
On 03.Dec 2004 - 18:25:19, Andreas Pakulat wrote:
Hi,
I've got a weird thing here. I have a function A in a product class that
Forget the previous description, the problem seems to be somewhere else. I have a form that uses enctype="multipart/form-data" and executes functionA(self, REQUEST). When I add "return REQUEST" into this function I see that the file-element is not a FileUpload Object, but a simple string?? I found the cause: method="POST" was not set. Question is: Is that OK, I mean can FileUpload only be use with POST not with GET? Andreas -- Your business will assume vast proportions.
Forget the previous description, the problem seems to be somewhere else. I have a form that uses enctype="multipart/form-data" and executes functionA(self, REQUEST). When I add "return REQUEST" into this function I see that the file-element is not a FileUpload Object, but a simple string??
I found the cause: method="POST" was not set. Question is: Is that OK, I mean can FileUpload only be use with POST not with GET?
Yes, files can only be uploaded with POST, it's due to how HTTP works. -- Phillip Hutchings http://www.sitharus.com/ sitharus@gmail.com / sitharus@sitharus.com
participants (2)
-
Andreas Pakulat -
Phillip Hutchings