[Zope] Re: How to upload an image?

Maik Jablonski maik.jablonski@uni-bielefeld.de
Tue, 22 Apr 2003 11:37:56 +0200


Jan Maška wrote:
> Hi there,
> 
> I'm trying to provide an editors' interface for front-end users, who I don't
> want to allow access to ZOPE management console (for obvious reasons - if
> you've ever developed for managers and marketing, you'll understand).. :-))
> 
> Right now, my problem is an interface for adding 'NEWS-like' items - press
> releases, announcements etc.
> Errata: No problem with item creation, but I need to enable users to add a
> single image to the news item.
> Is there a simple and reliable solution based on DTML or simple Python?
> e.g. <dtml-call "manage_addImage('imagename',$REQUEST.form['imagefile'])">
> ..?

Hi,

try it with a HTML-file-upload-form and a PythonScript, which handles 
storing the file/image in the ZODB:

DTML-Method with id=addFileForm:
--------------------------------
...
<form action="addFile" method="post" enctype="multipart/form-data">
  <input type="file" name="file">
  <input type="submit" value=" Upload ">
</form>
...

PythonScript with id=addFile; Paramter List = file
--------------------------------------------------

context.manage_addProduct['OFSP'].manage_addImage(id='',
                                                  title='', file=file)
return context.REQUEST.RESPONSE.redirect('whereDoYouWantToGo')

And that's it...

Cheers, Maik