diff --git a/fileHost.py b/fileHost.py
index d0d5ae9..f03fdb0 100755
--- a/fileHost.py
+++ b/fileHost.py
@@ -362,39 +362,41 @@ def index():
if request.method == "GET":
return render_template("index.html")
- file = request.files.get('file')
- fname = secure_filename(file.filename)
- pre = get_rand_chars(8)
- fdir = app.config.get("UPLOAD_DIR")
+ urls = []
+ for file in request.files.getlist("file"):
+ fname = secure_filename(file.filename)
+ pre = get_rand_chars(8)
+ fdir = app.config.get("UPLOAD_DIR")
- if request.form.get("randname") == "on":
- fname = pre + os.path.splitext(fname)[1]
- else:
- fname = pre + "_" + fname
+ if request.form.get("randname") == "on":
+ fname = pre + os.path.splitext(fname)[1]
+ else:
+ fname = pre + "_" + fname
- if request.form.get("delflag") == "on":
- try:
- delete_time = int(request.form.get("delnum"))
- assert delete_time >= 1 and delete_time <= 59
- except (ValueError, AssertionError):
- return 'Invalid entry: "delnum=' + request.form.get("delnum") + '"'
- del_dict = {"minute": 60, "hour": 3600, "day": 3600*24, "week": 3600*24*7}
- try:
- delete_time *= del_dict[request.form.get("deltype")]
- except KeyError:
- return 'Invalid entry: "deltype=' + request.form.get("deltype")+'"'
- delete_time = int(time.time()) + delete_time
+ if request.form.get("delflag") == "on":
+ try:
+ delete_time = int(request.form.get("delnum"))
+ assert delete_time >= 1 and delete_time <= 59
+ except (ValueError, AssertionError):
+ return 'Invalid entry: "delnum=' + request.form.get("delnum") + '"'
+ del_dict = {"minute": 60, "hour": 3600, "day": 3600*24, "week": 3600*24*7}
+ try:
+ delete_time *= del_dict[request.form.get("deltype")]
+ except KeyError:
+ return 'Invalid entry: "deltype=' + request.form.get("deltype")+'"'
+ delete_time = int(time.time()) + delete_time
- db_execute(
- "INSERT INTO UPLOADS (filename, uploaded_by, delete_date)"
- "VALUES (?,?,?)", (fname, username, delete_time))
- else:
- db_execute("INSERT INTO uploads (filename, uploaded_by) VALUES (?,?)",
- (fname, username))
+ db_execute(
+ "INSERT INTO UPLOADS (filename, uploaded_by, delete_date)"
+ "VALUES (?,?,?)", (fname, username, delete_time))
+ else:
+ db_execute("INSERT INTO uploads (filename, uploaded_by) VALUES (?,?)",
+ (fname, username))
- file.save(os.path.join(fdir, fname))
- url = app.config.get("UPLOAD_URL") + fname
- return url
+ file.save(os.path.join(fdir, fname))
+ url = app.config.get("UPLOAD_URL") + fname
+ urls.append(url)
+ return "
".join(urls)
def get_rand_chars(n):
diff --git a/templates/index.html b/templates/index.html
index ffeb396..52fc20f 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -10,7 +10,7 @@
Logout
Manage Uploads
Select file to upload: -
+
Generate random filename.
Delete this file in