Data Type for server-side formdata

I want to publish an audio file on my server. Here is how I am trying to do:

var fd = new FormData();
fd.append('fname', 'test.wav');
fd.append('data', soundBlob);
$.ajax({
    type: 'POST',
    url: '/test/testMethod',
    data: fd,
    processData: false,
    contentType: false
}).done(function(data) {
       console.log(data);
});

And on the server side, I have a method:

[HttpPost]
public void testMethod(??What datatype??  postedData)
{

}

What will be the data type for the parameter postedData? I tried using an object and a byte data type. Any help would help.

+4
source share
1 answer

I got this job using FormCollectionlike:

[HttpPost]
public void testMethod(FormCollection frmCollection)
{
    Request.Files[0]  //-- this gives you the posted file
}
0
source

Source: https://habr.com/ru/post/1611592/


All Articles