Controller Action
public class EstabelecimentoController : ControllerBase
{
[HttpPost]
public ActionResult ImportarEstabelecimentos()
{
var file = Request.Files["inputFileImportarEstabelecimentos"];
return RedirectToAction("Index");
}
}
HTML input snippet
Importar <input id="inputFileImportarEstabelecimentos" name="inputFileImportarEstabelecimentos" type="file" onchange="ImportarEstabelecimentos()" />
javascript snippet
<script type="text/javascript">
$(document).ready(function () {
});
function ImportarEstabelecimentos() {
$.ajax({
type: "POST",
url: "/Estabelecimento/ImportarEstabelecimentos",
datatype: "JSON",
contentType: "application/json; charset=utf-8",
data: {},
success: function() { alert('Success'); }
});
}