如何使用mod_python上传文件?

时间:2009-03-12 20:21:03

标签: python upload mod-python

我想创建一个简单的文件上传表单,但我必须完全没有能力。我已经阅读了文档和教程,但出于某种原因,我没有收到提交的表单数据。我编写了最少量的代码来测试它仍然无法正常工作。任何想法有什么不对?

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!"

1 个答案:

答案 0 :(得分:1)

尝试在表单标记中放入enctype =“multipart / form-data”。你的错误并不是与mod_python有关。

相关问题