[Zope] Image Upload detection
Alexander Staubo
alex@mop.no
Thu, 17 Jun 1999 19:56:52 +0200
There may be an easier way, but here's how I'm doing it.
In the DTML Method that is the target of the post, do something like
this (untested):
<!--#if image-->
<!--#call "REQUEST.image.seek(0, 2)"-->
<!--#if "REQUEST.image.tell() > 0"-->
<!--#call "REQUEST.image.seek(0)"-->
<!--#call "manage_addImage(REQUEST.image.filename, file =
REQUEST.image)"-->
<!--#/if-->
<!--#/if-->
This will determine the file size of the file and if non-zero, will add
it to the current folder.
The second seek might not be necessary (it depends on whether
manage_addImage() or whatever you do with the file does it).
PS: It's multipart _encoding_, not encryption. Basically the browser
just base64 encodes the data and sends it as text. HTTP/MIME supports
the "binary" content transfer encoding for a multipart value, which is
roughly 12.5% more efficient compared to base64, although I have never
checked whether modern browsers support this.
--
Alexander Staubo http://www.mop.no/~alex/
"`Ford, you're turning into a penguin. Stop it.'"
--Douglas Adams, _The Hitchhiker's Guide to the Galaxy_
>-----Original Message-----
>From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Phil
>Grove
>Sent: 17. juni 1999 19:26
>To: zope@zope.org
>Subject: [Zope] Image Upload detection
>
>
>Hello all,
>
>second question of the day.
>
>Right, how do you detect if an image has been provided for upload when
>using the MULTIPART encryption method on a form?
>
>Basically, i have got a form that uploads three images to Zope
>and the user
>has the choice to upload between 1 and 3 pictures, so
>obviously, i need to
>check if the file boxes are empty or not. For example:
>
><INPUT TYPE="file" NAME="newImg">
>
>at the zope end:
>
><!--#if newImg-->
> image is here
><!--#else-->
> nothing there matey boy
><!--#/if-->
>
>does not work.... any ideas on how to check???
>
>Please help, i am losing my hair very quickily....
>
>Cheers,
>
>P.
>
>---------------------------------------------------------------------
>
>Phil Grove phil.grove@flg21.com
>Web Development 0113 2949494
>flg21 http://www.flg21.com
>
>---------------------------------------------------------------------
>
>
>_______________________________________________
>Zope maillist - Zope@zope.org
>http://www.zope.org/mailman/listinfo/zope
>
>(For developer-specific issues, use the companion list,
>zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
>