js实现异步上传文件

使用:FormData (optional HTMLFormElement form)

var oMyForm = new FormData();
        oMyForm.append("file", document.getElementById('btn_as_import').files[0]);
        var oReq = new XMLHttpRequest();
        oReq.open("POST", "/hanhua/salaryAdjustmen.jsp");
        oReq.onreadystatechange=function () {
            if(oReq.readyState == 4 && oReq.status == 200){
                var b = oReq.responseText;
                alert(b);
            }
        }
        oReq.send(oMyForm);

转载于:https://my.oschina.net/u/3572510/blog/1548741

你可能感兴趣的:(js实现异步上传文件)