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!'
try putting enctype=’multipart/form-data’ in your form tag. Your mistake is not really mod_python related.