**Jquery Ajax call sending data to controller**
$("#btncareerssubmimt").click(function() {
var Name = $("#txtname").val();
var file = $("#fileresume").val();
$.ajax({
type: "POST",
url: '/Footer/sendmail',
data: { Name: Name ,file: file },
success: function() {
$("#simplecareers").html('<p style="color:#74ac12;margin-left:19%;">Your Request Submitted Successfully</p>');
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#simple-msg").html('<pre>"fail"</pre>');
}
});
}
在aboveo阿賈克斯CAL IAM得到正確名稱和文件路徑,但是,當我們傳遞給控制器 變得名存實亡,但文件路徑越來越空 我的HTML視圖asp.net的MVC使用jQuery AJAX CAL HttpPostedFileBase文件中獲取空值
<input type="text" name="txtname" id="txtname" class="form-control" value=""/>
input type="file" name="file" id="fileresume" value=""/>
<input type="submit" value="Upload" id="btncareerssubmimt" class="submit" />
This is my controller
[HttpPost]
public ActionResult sendmail(string Name ,HttpPostedFileBase fileresume)
{
}
檢查此問題http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery –