【问题标题】:How to upload multiple files with web.py?如何使用 web.py 上传多个文件?
【发布时间】:2014-10-19 11:03:46
【问题描述】:

我正在尝试使用 web.py 获取多个文件。 表格是这样的:

<form method="POST" action="/addProduct" enctype="mutipart/form-data">
    <input type="text" name="name">
    <input type="text" name="address">
    <textarea form="pro-form" name="des"></textarea>
    <input type="file" name="icon">
    <input type="file" id="uploadSc" name="screen">
    <input type="submit" value="submit">
</form>

Python代码如下:

class addProduct(Auth):
    def GET(self):
        return render.addProduct()

    def POST(self):
        i = web.input(icon={}, screen={})
        name, address, des, icon, screen =  i.name, i.address, i.des, i.icon, i.screen
        # print icon.filename
        print icon
        icon_dir = './static/product/icon/'
        # icon_dir = saveFile(icon, icon_dir)
        screen_dir = './static/product/screen/'
        # screen_dir = saveFile(screen, screen_dir)

        db.insert(product, pro_name=name, pro_url=address, pro_screenurl=screen_dir, pro_iconurl=icon_dir, pro_desc=des)
        return icon

服务器只返回图标的文件名,而不是它的值:(

【问题讨论】:

    标签: python web.py


    【解决方案1】:

    我现在知道答案了...
    我在这里拼错了multipart/form-dataas mutipart/form-data
    :(

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-10
      • 2019-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-10
      相关资源
      最近更新 更多