[Zope] Upload Image

Paul Zwarts paz@oratrix.com
Tue, 13 Nov 2001 20:10:45 +0100


Scott,

Using the LocalFS product, I have some DTML code that I use to upload
images for a URL database (its not pretty but it works):

<dtml-if "image.filename">
   <dtml-call "REQUEST.set('ext', image.filename[-3:])">
   <dtml-if "ext=='gif' or ext=='jpg'">
   <dtml-else>
      <span class="Text"> You can only upload a <span
class="Error">gif</span> or <span class="Error">jpg</span> type
image</span>
      <dtml-call "sData.set('action', 'add')">
   </dtml-if>
<dtml-else>
   <dtml-call "REQUEST.set('ext', '')">
</dtml-if>
<dtml-if "ext!=''"><span class="text1">uploaded</span>
   <dtml-call
expr="linkImage[_.str(sData.get('key1'))].manage_upload(id=_.string.repl
ace(ltitle,' ','+') + '.' + ext, file=REQUEST['image'])">
</dtml-if>

The secrets in this code you should be looking at is the last dtml-call.
What its doing is addressing the LocalFS mount called linkImage and then
the subdirectory underneath it which is a session variable. My link
database works on category types which are numerically ordered, i.e
linkImage/2/imagename.gif.

Then it deposits the image under the name of the title the person used
for the URL, replacing spaces with + so its html friendly. Much better
code could be used, but its not necessary for me because only myself and
other admins can run this code. 

I would advise you to be carefull with users uploading etc, etc as you
can rename malicious code as a gif that can be run on your server.

Cheers,
Paul Zwarts

-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org] On Behalf Of
Scott Kuei
Sent: Tuesday, November 13, 2001 7:31 PM
To: Zope@zope.org
Subject: [Zope] Upload Image

Hi,
I am trying to create a site which people can upload their image and
annotate the image as they are uploading. For example, description of
the image, date, author ...etc. And display the images in thumbnail
forms after uploading. Have anyone done the similar project before? Can
I get some hint or suggestions?
Scott,


_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )