Can anyone help me with saving canvas to my specific Flask folder? I retrieve image with canvas.toDataURL(), but have no idea how to upload it then
HTML:
{% block main %}
<form action="/draw" method="post">
<canvas id="canvas" style="border-style: solid;" width = "400" height = "400" ></canvas><hr>
<button type="button" id="startsave">Save</button>
JS:
window.addEventListener('load', () => {
document.getElementById('startsave').addEventListener('click', startsave);
});
function startsave() {
var ref = canvas.toDataURL("image/png");
var img = document.createElement("img");
img.setAttribute("src", ref);
img.setAttribute("name", "image");
// TODO
}
Flask:
@app.route("/draw", methods=["GET", "POST"])
@login_required
def draw():
if request.method == "GET":
return render_template("/draw.html")
else:
#TODO