How to pass excel file to controller using jquery ajax.

this is my view page

@model InnubexWebPortal.Models.CertificationModels

<input type="text" name="text" id="CampaignName" />

<input type="file" name="file" id="file"/>

<button type="button" name="Save" class="save" onclick="Campaign_save()">Save</button>

<script>
function Campaign_save() {

    var Campaign = { "CampaignName": ""};

    Campaign.CampaignName = $('#CampaignName').val();

  // How to get the uploaded file using jquery ?

 $.ajax({
    url: '/Certification/AddCampaign',
    data: JSON.stringify(Campaign),
    type: 'POST',
    contentType: 'application/json;',
    dataType: 'json',
    success: function (result) {
        if (result.Success == "1") {

        }
        else {
            alert(result.ex);
        }
    }
});
}

and in controller name is (certification) i wanr to get the uploaded excel file in my controller

    public JsonResult Uploadfile(Campaign Campaign, HttpPostedFileBase file)
    {
        How to get the uploaded file in controller.
    }

Related posts

Recent Viewed