Allow uploading multiple files with a single post to my saveserver

This commit is contained in:
Felix Van der Jeugt 2020-01-02 13:22:10 +01:00
parent 59cbbf78ec
commit 34a498e496
No known key found for this signature in database
GPG Key ID: 58B209295023754D

View File

@ -7,7 +7,7 @@ app = Flask(__name__)
FORM = """ FORM = """
<html> <html>
<form action="/" enctype="multipart/form-data" method="post"> <form action="/" enctype="multipart/form-data" method="post">
<input type="file" name="the_file" /> <input type="file" name="the_file" multiple="multiple" />
<input type="submit" name="submit" /> <input type="submit" name="submit" />
</form> </form>
</html> </html>
@ -16,8 +16,8 @@ FORM = """
@app.route("/", methods=["GET", "POST"]) @app.route("/", methods=["GET", "POST"])
def form(): def form():
if request.method == "POST": if request.method == "POST":
f = request.files["the_file"] for f in request.files.getlist('the_file'):
f.save('./' + secure_filename(f.filename)) f.save('./foto_' + secure_filename(f.filename))
return FORM return FORM