allow uploading multiple files

This commit is contained in:
iou1name 2018-06-05 06:58:18 -04:00
parent 2815e9e029
commit 6ac585d9f5
2 changed files with 32 additions and 30 deletions

View File

@ -362,7 +362,8 @@ def index():
if request.method == "GET":
return render_template("index.html")
file = request.files.get('file')
urls = []
for file in request.files.getlist("file"):
fname = secure_filename(file.filename)
pre = get_rand_chars(8)
fdir = app.config.get("UPLOAD_DIR")
@ -394,7 +395,8 @@ def index():
file.save(os.path.join(fdir, fname))
url = app.config.get("UPLOAD_URL") + fname
return url
urls.append(url)
return "<br />".join(urls)
def get_rand_chars(n):

View File

@ -10,7 +10,7 @@
<a href="{{ url_for('logout') }}">Logout</a><br />
<a href="{{ url_for('manage_uploads') }}">Manage Uploads</a><br />
<p>Select file to upload:
<p><input type="file" name="file" required/><br />
<p><input type="file" name="file" required multiple/><br />
<input type="checkbox" name="randname"/> Generate random filename.<br />
<input type="checkbox" name="delflag"/> Delete this file in <input type="number" name="delnum" min="1" max="59" value="1"/>
<select name="deltype">