diff --git a/run.py b/run.py index 869eb87..0fcd1ef 100755 --- a/run.py +++ b/run.py @@ -79,10 +79,13 @@ def upload_file(): # Only continue if a file that's allowed gets submitted. if file and allowed_file(file.filename): - if config["CHECK_FILESIZE"]: - data = request.files["file"].read() - if len(data) >= config["MAX_FILESIZE"]: - return error_page("O-o-onii-chan, noo it's too big ~~"), 413 + try: + if config["CHECK_FILESIZE"]: + data = request.files["file"].read() + if len(data) >= config["MAX_FILESIZE"]: + return error_page("O-o-onii-chan, noo it's too big ~~"), 413 + except Exception: + pass filename = secure_filename(file.filename) while os.path.exists(os.path.join(config["UPLOAD_FOLDER"], filename)): filename = str(randint(1000,8999)) + '-' + secure_filename(filename)