views:

801

answers:

1

I want to create a simple file upload form and I must be completely incapable. I've read docs and tutorials,but for some reason, I'm not getting the submitted form data. I wrote the smallest amount of code I could to test and it still isn't working. Any ideas what's wrong?

def index():
    html = '''
    <html>
      <body>
      <form id="fileUpload" action="./result" method="post">
        <input type="file" id="file"/>
        <input type="submit" value="Upload"/>
      </form>
      </body>
    </html>
    '''
    return html

def result(req):
    try: tmpfile = req.form['file']
    except:
        return "no file!"
A: 

try putting enctype="multipart/form-data" in your form tag. Your mistake is not really mod_python related.

Vasil
that's was the problem. I went back and looked at the mod_python docs and their example doesn't have that tag.
scottm