I am trying to upload file in my application.
For that in my view I have
<div>
<input id="Excelfile_id" type="file" value="Insert" class="import1" />
</div>
<div>
<input type="button" id="excelbutton_id" value="import" class="import2" />
</div>
Jquery function is,
$.ajax({
type: 'POST',
url: '@Url.Action("import")', // we are calling json method
dataType: 'json',
contentType: 'multipart/form-data',
data: { db: dbConn, excelfile: $("#Excelfile_id").attr('files') },
success: function (listofuser) {
// region contains the JSON formatted list
// of region passed from the controller
if (!listofuser.empty) {
and my controller is,
public JsonResult import(HttpPostedFileBase excelfile)
{
if (excelfile.ContentLength == 0 || excelfile == null)
So, i am getting error in controller for excelfile variable as null reference.
Could you please suggest?
Thanks