界面上传文件js包【AjaxUpload.js】

function uploadFile() {
    new AjaxUpload($("#importFile"), {
        action: url,
        type: "POST",
        data: {"userId": userId},
        autoSubmit: true,
        responseType: "json",
        name: 'file',
        onSubmit: function (file, ext) {
            if (!(ext && /^(rar|zip|pdf|pdfx|txt|csv|xls|xlsx|doc|docx|RAR|ZIP|PDF|PDFX|TXT|CSV|XLS|XLSX|DOC|DOCX)$/.test(ext))) {
                pNotifyAutoCloseCenter("fail", "您上传的文档格式不对,请重新选择!", "error");
                return false;
            }
            console.log("onsubmit");
        },
        onComplete: function (file, response) {
            pNotifyAutoCloseCenter("info", "数据上传" + response.status + "!", "info");
            console.log("upload file complete, savePath: " + response.savePath);
        }
    });
}
原文地址:https://www.cnblogs.com/onetwo/p/5499259.html