locked
How to pass IFormFile data from javascript to c# action method model for the file uploaded mvc6 RRS feed

  • Question

  • User-728602463 posted

    How to pass IFormFile data from javascript to c# action method model for the file uploaded mvc6:-

     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

    Wednesday, October 12, 2016 12:20 PM

Answers