ca1n
V2EX  ›  Flask

flask 模板中的 {{ wtf.quick_form(form) }} 怎么用来上传文件呢?

  •  
  •   ca1n · May 16, 2015 · 7002 views
    This topic created in 4046 days ago, the information mentioned may be changed or developed.

    使用wtf.quick_form()得到的上传按钮进行上传,WTF的官方文档对于上传文件是这样说的

    请记得设置 HTML 表单的 enctype 为 multipart/form-data

    这里不设置的结果就是以_application/x-www-form-urlencoded_传递了文件,造成传递文件的时候文件内容丢失只剩下文件的名称
    常試在{{ wtf.quick_form(form) }} 外面嵌套<form ... enctype='...'>,沒有效果

    现在的做法没有使用wtf的quick-form来将类转为表单,而是手动设置了一个上传按钮,有什么更好的解决办法吗?
    或则说 当使用quick_form的時候,怎么设置enctype呢?

    ca1n
        2
    ca1n  
    OP
       May 16, 2015
    @linnchord wow,thx
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2616 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 16:02 · PVG 00:02 · LAX 09:02 · JFK 12:02
    ♥ Do have faith in what you're doing.