Send file upload data from AngularJS to C# backend -


i'm trying upload file , want send upload file data c# back-end. having code:

html

<input type="file" id="upload" name="file" onchange="angular.element(this).scope().uploadedfile(this)" multiple /> 

angularjs serivce

uploadfile: function (files, type, status) {     var route = 'api/sc/ir/cid/' + $cookies.get("cid") + '/type/' + type + '/status/' + status;     (var = 0; < files.length; i++) {       $http.post(servicebase + route, files[i], {         withcredentials: false,         transformrequest: angular.identity,         headers: { 'content-type': 'application/json' }       })     }     return true;   } 

c# controller

    [httppost]     [route("api/sc/ir/cid/{cid:int}/type/{type}/status/{status}")]     [responsetype(typeof(validatemodel))]     public ihttpactionresult addfilerequests(int cid, string type, string status, httppostedfilebase file)     {         var newrequest = logic.uploaddocument(clinicid, type, status, file);         return created(request.requesturi.tostring(), newrequest);     } 

the problem 'file' object null when getting back-end, it's nicely populated in front-end. missing?


Comments