[Zope] file upload from python script

Horst Wald horstwald@hotmail.com
Mon, 03 Sep 2001 16:19:16 +0000


Hi,

I'm trying to do a file upload from inside a python script that takes the 
file's path and the target folder object as args.

When I try manage_addFile or manage_upload, the content of the new Zope-file 
is the path of the file I wanted to upload and not the file itself.

File upload works fine from a DTML-Method which takes the file's path (and 
something more I think) from a DTML-Document using a
<input type="file">-tag. I found them somewhere in the internet and I'll 
list them below in case they'll help you helping me.

Thanks in advance

Horst

DTML-Doc "DateiBagger":

<html>
<h2><dtml-var title_or_id></h2>
<table border=0>
<form action="SchaufelBagger"  enctype="multipart/form-data" method="post">
<tr>
<td><b>Datei:</b></td>
<td><input type="file" name="DateiName"></td>
</tr>
<tr><td></td><td>
<input type=submit value="HochSchaufeln"></td></tr>
</form>

DTML-Meth "SchaufelBagger", called by the previous document:

<html>
<h2><dtml-var document_id></h2>
<dtml-let fname="_.string.split(DateiName.filename,'\\')[-1]">
<dtml-with upload>
<dtml-if "_.has_key(_['fname'])">
<dtml-call "_[_['fname']].manage_upload(REQUEST.form['DateiName'])">
<p><dtml-var fname> wurde hochgeschaufelt, alte Fassung wurde ersetzt.</p>
<dtml-else>
<dtml-call "manage_addFile(_['fname'], REQUEST.form['DateiName'])">
<p><dtml-var fname> wurde hochgeschaufelt.</p>
</dtml-if>

<form action="upload/<dtml-var fname>" method="post">
<input type=submit value="Ansehen">
</form>

</dtml-with>
</dtml-let>
<dtml-var standard_html_footer>


</table>
<dtml-var standard_html_footer>



_________________________________________________________________
Downloaden Sie MSN Explorer kostenlos unter http://explorer.msn.de/intl.asp