Fix file upload
This commit is contained in:
parent
6e6c35a222
commit
3dc40ea3dc
7 changed files with 4 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,7 +2,7 @@
|
|||
.secret_key
|
||||
.bundle/config
|
||||
logs/
|
||||
uploads/
|
||||
files/
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
|
|
|
@ -37,14 +37,9 @@ def problem_add():
|
|||
if len(filename) == 0:
|
||||
continue
|
||||
|
||||
folder = problem.name.replace(" ", "-")
|
||||
folder_path = os.path.join(os.path.normpath(app.config["UPLOAD_FOLDER"]), folder)
|
||||
if not os.path.exists(folder_path):
|
||||
os.makedirs(folder_path)
|
||||
|
||||
file_path = os.path.join(folder_path, filename)
|
||||
file_path = os.path.join(app.config["UPLOAD_FOLDER"], filename)
|
||||
_file.save(file_path)
|
||||
db_file = Files(problem.pid, file_path)
|
||||
db_file = Files(problem.pid, "/".join(file_path.split("/")[2:]))
|
||||
db.session.add(db_file)
|
||||
|
||||
db.session.commit()
|
||||
|
|
|
@ -15,7 +15,7 @@ SECRET_KEY = key
|
|||
SQLALCHEMY_DATABASE_URI = "mysql://root:i_hate_passwords@localhost/easyctf"
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
|
||||
UPLOAD_FOLDER = os.path.normpath("files")
|
||||
UPLOAD_FOLDER = os.path.normpath("../web/files")
|
||||
|
||||
CTF_BEGIN = 0 # To be used later
|
||||
CTF_END = 0 # To be used later
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
This is hard! I'm telling you!
|
|
@ -1 +0,0 @@
|
|||
Binary is not fun at all!
|
|
@ -1 +0,0 @@
|
|||
This is an example file, and should be removed before the tournament starts.
|
|
@ -1 +0,0 @@
|
|||
Hello World! How art thou?
|
Loading…
Reference in a new issue