jquery基于form-data文件上传

1.html代码

<input type="file" name="myupdate" id="myupdate">

2.javascript代码

var fd = new FormData();
fd.append("myupdate", $('#myupdate')[0].files[0]);
 $.ajax({
    url: posturl,
    type: 'post',
    processData: false,
    contentType: false,
    data: fd,
    success: function (res) {
             //do something           
    }
});
原文地址:https://www.cnblogs.com/jasonlai2016/p/10775050.html