Reputation: 1
I want to upload files using Jquery Ajax with Form Data.Like this
function UploadFile(i) {
var data = new FormData();
var files = [];
if ($('#PrintingSide').val() == "1") {
files.push($("#FrontFile" + i).get(0).files);
}
else {
files.push($("#FrontFile" + i).get(0).files);
files.push($("#BackFile" + i).get(0).files);
}
for (var i = 0; i < files.length; i++) {
data.append(files[i].name, files[i]);
}
$.ajax({
type: "post",
url: "@Url.Content("~/UserEstimation/UploadMultipleFiles")",
processData: false,
contentType: false,
data: data,
success: function (data) {
}
});
}
but in my action method i am getting 0 files.where i am doing the mistake?
I have 2 independent input file types,like this :
Controller:
public ActionResult UploadMultipleFiles()
{
for (int i = 0; i < Request.Files.Count; i++)
{
// do something here
}
}
Upvotes: 0
Views: 59
Reputation: 1
After 6 hour of Search and findings,I got solution of this weird issue.. the problem was file size, i just made some changes in web.config and Hurrehh..
<httpRuntime targetFramework="4.5" maxRequestLength="2097151" />
Upvotes: 0