我在提交表单时收到了404错误提示。我试图通过该表格上传并提交.png,按理来说服务器(Python,Flask)应该能够使用它才对......有人知道我的问题出在哪里吗?
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"
提前感谢你的解答!