[Zope] overwriting images revisited

Darcy Clark darcyc@engin.umich.edu
Tue, 14 Dec 1999 19:19:10 -0500


I have trolled through the mailing list archives (wish this stuff was in
the docs!!), I found some references to the use of manage_addImage and
the manage_upload methods....just enought o get myself into trouble it seems.

I have a form that prompts users for
 
<input type="text" name="id" size="20"> 
<input type="file" name="image">

i.e.  id is the name of image, and file is the file to be uploaded to
Zope. the action of this form is the added_new_staff method below :

<dtml-with REQUEST>
<dtml-with form>
<dtml-if "REQUEST.has_key('image')"> 
	<dtml-if "(REQUEST.image.seek(0, 2) or REQUEST.image.tell()) > 0">
		<!-- if no image is found -->
		<!--#call "manage_addImage(REQUEST['id'],REQUEST['image'],'')"-->
	<dtml-else>
		<!-- if image is found and needs to be overwritten -->
	 	<dtml-with "_[id]">
			<!--#call "manage_upload(REQUEST['id'],REQUEST['image'])"-->
		</dtml-with>
	</dtml-if>
</dtml-if>   
</dtml-with>
</dtml-with>

if the image doesn't exist, then it is uploaded through manage_addImage
- this part works well. But if the image is found, then unfortnately the
manage_upload doesn't work for me. I get the error :

Error Type: Bad Request
Error Value: The id test is invalid - it is already in use.

I would like to be able to overwrite existing images. Am I making any
obvious mistakes here ?

thanks for any help,

Darcy