[Zope] form-upload.
CHOY,CHARLENE (HP-Boise,ex1)
charlene_choy@hp.com
Wed, 25 Jul 2001 13:22:14 -0700
Hi,
Can someone please tell me what's wrong with this code. They are use to
upload a file. When I tried to implement it, it gave me an error
message:"unsubscriptable object" in the key error value. THe following is
the code that I use. These codes were posted in one of the zope discussion
board a while ago.
#########################################
DTML method with ID: upload_form
#########################################
<dtml-var standard_html_header>
<table border=0>
<form action ="saveFile" enctype="multipart/form-data' method="post">
<tr>
<td><b>File<b></td>
<td><input type="file" name="theFile" size="30" accept="*/*"></td>
</tr>
<tr><td></td><td>
<input type="submit" value="Upload"></td></tr>
</form>
<dtml-var standard_html_footer>
####################################
DTML method with ID: saveFile
####################################
<dtml-var standard_html_header>
<dtml-let
fname="_.string.split(REQUEST.form.['theFile'].filename,'\\')[-1]">
<dtml-with upload>
<dtml-if "_.has_key(_['fname'])">
<dtml-call "_[_['fname']].manage_upload(REQUEST.form['theFile'])">
<p>File was uploaded<p>
<dtml-else>
<dtml-call "manage_addFile(_['fname'], REQUEST.form['theFile'])">
<p>file was uploaded</p>
</dtml-if>
</dtml-with>
</dtml-let>
<p>
Thanks
<dtml-var standard_html_footer>
################################################################
Also could you please explain what do the following line means:
<dtml-let
fname="_.string.split(REQUEST.form.['theFile'].filename,'\\')[-1]">
Why is the "[-1]" being placed there?
Any help will be very much appreciated =).
-Charlene