[Zope] Adding IMAGE with manage_addImage is impossible :)

Alexander Staubo alex@mop.no
Sun, 24 Oct 1999 12:41:43 +0200


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 )
>