File Upload Problem

mee-shell jadethacker at
Fri Nov 5 00:26:23 CET 2004

I have a page with the file upload as the following:

<form action="UploadConfirm.psp" method="post"
<input type="file" name="UploadFile"><br><br>
<a href="javascript:document.forms[0].submit();">submit</a><br><br>

after submit, I'd like to retrieve the file name, and I have written
something like this:

import sys
import os

if form.has_key('UploadFile'):
   TheFile = form['UploadFile']
   filename = TheFile.filename

   TheFile = 'No file was uploaded, im empty'
   filename = ''


when I tested it, I got an error after submitting a file, and the
error message was:
AttributeError: 'StringField' object has no attribute 'filename'

Can anyone tell me what cause the problem and how I can fix it? 
Thanks a lot.

More information about the Python-list mailing list