做一个上传并解压的功能,解压完了回调,解压多少文件。搞了半天用Ajax.BeginForm。各种坑,后来直接放弃
@using (Ajax.BeginForm("UploadFile", "ChaptersAndsections", new AjaxOptions() { HttpMethod = "post", OnSuccess = "onSuccess", OnFailure = "onFailure", OnComplete = "onComplete" }, new { data_ajax = "false", enctype = "multipart/form-data"})) {}
去掉这个吧,后台获取不到文件名,加上吧不执行回调,这个真。。。(真心想用,但是搞不定)哪个园友可以解决,请留言
换种方法吧
请选择要解压的文件
function UploadUnZip() { var form = document.getElementById('uploadfrm'); var formData = new FormData(form); $.ajax({ url: "/ChaptersAndsections/UploadFile", type: "POST", data: formData, processData: false, contentType: false, success: function (data) { //这个地方可以填写自己的方法 document.getElementById("response").innerHTML = data; } }); }
如下:
后台