0

I am trying to upload an image using jQuery AJAX and not sure how to go around doing it...

I am trying to send the data to controller just to see it working...

Here is my code

<form enctype="multipart/form-data">
    <div class="form-group">
        <input type="file" id="myFile">
    </div>
    <button type="button" id="uploadHero" class="btn btn-primary">Upload</button>
</form>


$("#uploadHero").click(function () {
    var data = new FormData();
    var files = $("#myFile").get(0).files;

    $.ajax({
        type: "POST",
        url: "Home/FileUpload",
        data: data
    });
});

    [HttpPost]
    public void FileUpload(HttpPostedFileBase heroFile)
    {


    }

0 Answers0