i am getting a 404 error when submitting a form. I try to upload a .png through that form and submit it right after the upload. Then the Server (Python, Flask) should be able to work with that. Does anyone know where my issue is?
AJAX:
<script>
document.getElementById("exampleFormControlFile1").onchange = function() {
console.log("Came here");
$.ajax({
url:'/uploadPNG/',
type:'post',
data:$('#exampleFormControlFile1').serialize(),
success:function(){
console.log("Came here");
}
});
};
</script>
HTML:
<form method="POST" id="form">
<div class="form-group">
<label for="exampleFormControlFile1">Upload your .png template</label>
<input type="file" class="form-control-file" id="exampleFormControlFile1">
</div>
</form>
SERVER:
@app.route('/uploadPNG/', methods=['POST'])
def upload():
if request.method == 'POST':
print("Got png")
return "gotcha"
Thank you in advance