[Zope] (possible) Answer to: What to do if manage_addImage up loads are corrupted?

Alexander Staubo alex@mop.no
Mon, 25 Oct 1999 09:29:06 +0200


> From: Samu Mielonen [mailto:ex@uiah.fi]
> Sent: 24. oktober 1999 14:31
> To: Alexander Staubo; mj@antraciet.nl
> Cc: Zope Mailing List
> Subject: [Zope] (possible) Answer to: What to do if manage_addImage
> uploads are corrupted?

[snip]
> You wouldn't know how to test if a REQUEST.image1 exists or not before
> actually using manage_addImage or manage_upload on that image?

Test on the content type of the file object, or check whether the file
object's file attribute contains a non-zero file (eg., call seek(0, 2)
and then check if tell() returns > 0).

The following code illustrates the latter:

  <dtml-if "REQUEST.has_key('MyFile')">
    <dtml-if "(MyFile.file.seek(0, 2) or MyFile.file.tell()) > 0">
      <!-- file is valid -->
    </dtml-if>
  </dtml-if>

> Best regards,
> 	Samu Mielonen

Hope this helps,

-- 
Alexander Staubo             http://www.mop.no/~alex/
The difference between theory and practice is that, in theory,
there is no difference between theory and practice.