I want to create a simple form for uploading files, and I must be completely incapable. I read documents and textbooks, but for some reason I do not receive the form data provided. I wrote the smallest amount of code I could test, and it still doesn't work. 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!"
source
share