Folder and files upload with Flask

前端 未结 2 2026
旧巷少年郎
旧巷少年郎 2020-12-28 08:19

I can upload a File with flask by following Uploading Files:

  1. A
    tag is marked with enctype=multipart/form-data and an
相关标签:
2条回答
  • 2020-12-28 09:22
    file = request.files['file']
    

    change it to

    file = request.files['file[]']
    
    0 讨论(0)
  • 2020-12-28 09:24

    the issue here is that flask's app.config isn't relative to itself, it's absolute. so when you put:

    UPLOAD_FOLDER = './uploads' 
    

    flask doesn't find this directory and returns a 500 error. if you changed it to:

    UPLOAD_FOLDER = '/tmp'  
    

    and then uploaded your file and navigated to the /tmp/ directory you would see it.

    you will need to edit your path to the proper directory for the file to be uploaded properly.

    0 讨论(0)
提交回复
热议问题