RE: [Zope] Adding IMAGE with manage_addImage is impossible :)
Are you specifying the encoding type? Images are binary and must be base64-encoded by the browser. (There is also a raw binary transfer method, but I forget whether it is supported by any browsers.) If you omit the encoding type, Zope will not be able to recognize its file type, and it will be handled as plaintext data. Specify the form tag thus: <form action="..." method="post" enctype="multipart/form-data"> ... </form> -- Alexander Staubo http://www.mop.no/~alex/ "QED?" said Russell. "It's Latin," said Morgan. "It means, 'So there you bastard'." --Robert Rankin, _Nostramadus Ate My Hamster_
-----Original Message----- From: Samu Mielonen [mailto:ex@uiah.fi] Sent: 24. oktober 1999 12:13 To: Zope Mailing List Subject: [Zope] Adding IMAGE with manage_addImage is impossible :)
I can't add an image from a submit form using manage_addImage regardless of whatever I do.
Yes, I've read all the documentation (even the source code for image) 10 times already :)
I can only manage to save the path of my image (from my local harddrive) as content type text/plain when I use the manage_addImage to try and save the submitted image (not the path).
I do not understand what I'm doing wrong. I've tried every single piece of code on the Zope mailing list since 1998 (from archives) concerning manage_addImage and I can only conclude one thing:
Adding images is way too difficult :)
Here's what I try to do (simplified):
within a context of a sub-sub-folder (name is, say 'xyz'):
edit.html =========
<form action=postit method=post> <input type=file name="image1"> <input type=submit value="Tallenna muutokset"> </form>
postit ====== <dtml-if "image1"> <dtml-call "manage_addImage('temp_img', REQUEST.image1, 'testing images')"> </dtml-if>
and the result is a corrupted image file of content type "text/plain" with the size of of my image path in bytes. Both edit.html and postit are inside the same folder and my folderish object can contain image type sub-objects.
What am I doing wrong? From above it seems that image1 is a string object, but if so, then where's the uploaded file I'm sending through the submit form? How do I reference it? Is there any way to list all submit form property names (variables) and their contents (values) so that I can easily debug any problem like this?
Once again, all help is very much appreciated.
Best regards, Samu Mielonen
PS Having browsed through all of the Zope mailing list archives I've noticed I was alone with this problem. At least 8 other people had the same problem as I did. How can referencing a simple image object be so darned difficult? :)
-- "Our reflections on the order of society, as well as nature, are still dominated by the Newtonian image of massive power, exerted by sovereign agency through the operation of central force..." -Stephen Toulmin, "Cosmopolis"
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(Related lists - please, no cross posts or HTML encoding!
To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
I had a problem: using manage_addImage to create an image inside a Zope folder out of a submit form REQUEST object resulted in a image file with content type text/plain and wrong size (i.e. my REQUEST.image turned out to be a string object and not an image object, resulting in text string being saved as an image). Both Martin and Alexander recommended the following:
<form action="..." method="post" enctype="multipart/form-data"> ... </form>
Duh! (i.e. if you do not specify in your submit form the encoding type and that you are sending multi-part data, then the image will not be uploaded. Only the pathname to the image will be uploaded). <crawling under the rock in shame and swearing to check one's own code in the *right* place before posting> Thank you :) You wouldn't know how to test if a REQUEST.image1 exists or not before actually using manage_addImage or manage_upload on that image? Using any of the following if conditions always return TRUE (regardless of whether I've picked an image to be uploaded in my submit form). Please note that image1 is from: <input type=file name=image1> tag that is part of the form that sends the multipart/encoded data to the following dtml-method: <dtml-if image1> <dtml-if "image1"> <dtml-if "REQUEST.image1"> <dtml-if "not image1==''"> <dtml-if "not REQUEST.image1==''"> Because the if-clause (any of above) always returns true, I end up saving NOTHING in place of an image when the submit form didn't include an image (via property image1). Best regards, Samu Mielonen PS BTW, I couldn't find a reference to enctype="multipart/form-data" in any of the broken image upload messages in archives, so I posted this to the list as well.
participants (2)
-
Alexander Staubo -
Samu Mielonen