为什么提交表单时收到了404错误?

我在提交表单时收到了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"

提前感谢你的解答!

I just figured out the issue. Gonna answer my own post here so that others may have it easier. A magic wizard once told me to always check the documentation. http://flask.pocoo.org/docs/1.0/patterns/fileuploads/ Then I had to adjust the AJAX call like here: 'append' called on an object that does not implement interface FormData And then i had to add the name "file" to the input tag.