我在我的控制器中有这个操作。
public ActionResult Upload(HttpPostedFileBase fileData)
{
//code for uploading goes here.
return View();
}
有没有办法使用$.post或$.Ajax访问此操作? 在我的视图中,我有以下代码。
<input type="file" name="fileData" id="fileData" multiple/>
<button>Upload</button>
我首先尝试使用这段代码
$("button").on("click",function(){
$.post('@Url.Action' + $(".filedata").val(),function(data){
console.log(data);
});
});
但是,当我尝试在我的“上传”操作上设置断点时,“filedata”变量的值为null。
我不知道问题出在哪里。希望你们能帮帮我。
<iframe/>
或其他异步上传方法,比如http://www.plupload.com/或http://code.google.com/p/swfupload/。 - DanielB