【问题标题】:How do I upload a file with mod_python?如何使用 mod_python 上传文件?
【发布时间】:2010-10-13 00:33:09
【问题描述】:

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

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

【问题讨论】:

  • 你在使用 web2py 框架吗?
  • “不工作”是什么意思?你有错误跟踪吗?另外,你为什么不使用 mod_wsgi?
  • @S.Lott “我没有收到提交的表单数据。”我不知道 wsgi。
  • @scotty2012:“没有得到”——这是什么意思?追溯?安静? 404错误? 500错误?请参阅code.google.com/p/modwsgi 以获得比 mod_python 更好的界面。

标签: python upload mod-python


【解决方案1】:

尝试将 enctype="multipart/form-data" 放在您的表单标签中。您的错误与 mod_python 无关。

【讨论】:

  • 这就是问题所在。我回去查看了 mod_python 文档,他们的示例没有那个标签。
猜你喜欢
  • 1970-01-01
  • 2013-10-24
  • 1970-01-01
  • 2015-10-28
  • 1970-01-01
  • 1970-01-01
  • 2011-01-16
  • 2012-11-05
  • 2015-08-08
相关资源
最近更新 更多