[Zope] Uploading Picutres via WebForm?

Peter Bengtsson mail@peterbe.com
Tue, 5 Jun 2001 11:21:36 +0200


Have a look at 
<zope>/lib/python/OFS/Image.py

They use a method they call cookId()
Look at that.
----- Original Message ----- 
From: "Philipp Robbel" <philipp.robbel@eml.villa-bosch.de>
To: <zope@zope.org>
Sent: Saturday, June 02, 2001 4:44 PM
Subject: [Zope] Uploading Picutres via WebForm?


> Hello everybody,
>  
> I have a question regarding the upload of pictures through a webform.
> Right now my code only works with a 'hard-coded-ID'-value (see below).
>  
> ===== code (dtml method "upPicture" - calls itself after submitting file
> selection form) =====
> <dtml-if expr="REQUEST.form.keys()">
>    <dtml-if "attached_file.filename"> <!-- check if user entered
> something in the form -->
>       <dtml-call "manage_addImage('HARD_CODED_ID', attached_file.read(),
> ' ')">
>    <dtml-else>
>       Please choose a picture!!!.
>    </dtml-if>
> <dtml-else>
>    <h2>Upload Picure:</h2>
>    <p><form method="post" action="upPicture"
> enctype="multipart/form-data">
>          <input type="file" name="attached_file"> 
>          <input type=submit name="submit">
>       </form>
> </dtml-if>
> ===============================================================
> The above code works fine, it creates a new image object out of the
> selected file.
>  
> But what I want is to change the HARD_CODED_ID into the current
> filename, i.e. if the person selects "C:\Temp\pic.jpg" for uploading I
> want the function manage_addImage to be called with the following
> arguments:
>     'pic.jpg', attached_file.read(), ' '
>  
> I tried dtml-call "manage_addImage(attached_file, attached_file.read(),
> ' ')">
> or:                    "manage_addImage(attached_file.filename,
> attached_file.read(), ' ')">
>  
> I couldn't get it to work.
>  
>  
> Thanks for your help in advance,
> Philipp
>  
> 
>  
>