Allow uploading multiple files with a single post to my saveserver
This commit is contained in:
parent
59cbbf78ec
commit
34a498e496
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user