I have a page made in HTML and JavaScript , in this I have a form with several inputs
among them is a input file
, and I send them to server through Ajax and JS .
On the server side I receive the data of inputs
, but upon receiving the input file
I get an error of data type is incorrect.
My question is: What kind of data do I have to use on the server side ( ASP.net and C # ) in order to receive the file correctly?
Here part of the code I have:
HTML
<form id='frm1'>
<input type='text' id='nombre'>
<input type='file' id='balance'>
</form>
JavaScript
fuction guardar(){
var nombre = $('#nombre').val();
var files = $("#balance").get(0).files;
PageMethods.Guardar(nombre,files[0],guardar_Callback, Failed_CallBack,context);
}
On the server side, I have the following method:
[WebMethod()]
public static int guardar(string nombre, tipoArchivo balance){
//lo que haga con la informacion
}
As I comment with the exception of the type of data to receive the file, everything works fine.