I get form page through Ajax. The following is a form of code:
enter code here
<form  method="post" enctype="multipart/form-data" class="form-horizontal">
    <div class="form-group" style="margin-left:0px;">
        <label for="file">注:选择头像文件尽量小于2M</label>
        <input id="headPortraitFile" type="file" name="portrait"> 
    </div>
    <button id="headPortraitSubmit" type="button" class="btn-sm btn-primary">上传头像</button>
</form>
But the form of the input type = "file" in the browser cannot selected file directly, not to mention the submitted documents. I do not know what reason be? This two days have not been solved, for a great god!!!!!!
here is the Ajax code: 1.I get the form page by this:
$(Document).on("click", '#headPortrait', function() {
    $.get("/headPortrait", function(data) {
        $(".bodyPart").children().remove();
        $(".bodyPart").html(data);
    })
})
2.and then I post the form by this:
$(Document).on("click", '#headPortraitSubmit', function() {
    var formData = new FormData();
    formData.append("portrait", $('#headPortraitFile').get(0).files[0])
    $.ajax({ 
        url : "/headPortraitSubmit", 
        type : 'POST', 
        data : formData, 
        processData : false, 
        contentType : false,
        beforeSend:function(){
            console.log("正在进行,请稍候");
        },
        success : function(data) { 
            if (data = "success") {
                $(".bodyPart").children().remove();
                $(".bodyPart").load('/coding');
            }
        }, 
    });
})
 
    