Skip to content

Instantly share code, notes, and snippets.

@yarickprih
Created December 1, 2021 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yarickprih/3ff259cd38eea2a4b0e462b76a74213d to your computer and use it in GitHub Desktop.
Save yarickprih/3ff259cd38eea2a4b0e462b76a74213d to your computer and use it in GitHub Desktop.
@app.route("/upload", methods=["GET", "POST"])
def upload_file():
form = FileUploadForm()
if form.validate_on_submit():
file = form.document.data
file_name = secure_filename(file.filename)
save_path = get_user_uploads_folder(current_user) / file_name
file.save(save_path)
flash("File uploaded successfully", category="success")
return redirect(url_for("list_user_files"))
flash_form_errors(form)
return render_template("upload_file.html", form=form)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment