2
Reply

How to pass IFormFile data from js code to c# action method

Gaurav Babbar

Gaurav Babbar

Oct 12 2016 8:27 AM
732

var onFileUploadChange = function () {        

var originalEvent = document.getElementById("fileUpload");        

var files = originalEvent.files;

        if (typeof FormData == "undefined") {            

var data = [];         }        

else {           

var data = new FormData();       

}

        for (var i = 0; i < files.length ; i++) {            

data.append(files[i].name, files[i]);  break;       

}     

$.ajax({            

type: "POST",            

url: _url,            

dataType: "html",            

contentType: false,            

processData: false,            

data: data,            

success: function () {             },           

error: function (xhr) {                

console.log(xhr);            

}        

});   

}


I will get the values in "Request" object at c# action method, Is there any way that I will get this value in action method parameter model instead.????

Thanks


 


Answers (2)