Question: I'm trying to pass a file to my aspnet project without using FormData, all the values are sent but the file itself. So I was able to `if ($('#Prop').get(0).files.length === 0` check if theres something in there but I can't send it. The model behind has a `HttpPostedFileBase` property and I was trying to send with :

`$('#Prop').get(0).files`

`$('#Prop').val()`

Not working!

Answer: 
If you are using MVC structure you can use below code:

MVC razar syntax provides **@Ajax.Beginform()**, here you can send "multipart/form-data".

```
@using (Ajax.BeginForm("action", YourController, new { id= Model.Id }, new AjaxOptions {needed options }, new { enctype = "multipart/form-data" }))
{
    <input type="file" id="fileid" name="filename" />
    <input type="submit" value="Modify" />
}

```
You can use this to send file to controller
in view
function UploadTemplate() {

```
    var filename = $("#ProcessTemplateUpload").val();

    var re = /\..+$/;
    var ext = filename.match(re);

    if (ext == '.xlsx' || ext == '.XLSX' || ext == '.xls' || ext == '.XLS') {

        var data = new FormData();
        var files = $("#ProcessTemplateUpload").get(0).files;
        if (files.length > 0) {

            data.append("HelpSection", files[0]);

            $.ajax({
                url: '@Url.Content("~/Process/UploadProcessTemplate")',
                type: "Post",
                dataType: "HTML",
                processData: false,
                data: data,
                contentType: false,
                beforeSend: function () { $("#divLoading").show(); },
                success: function (result) {
                    debugger;
                    $("#divLoading").hide(); // clear before appending new list

                    alert(result);
                },
                error: function (xhr, status) {
                    alert("Uploading Failed Please Select Correct File"); // clear before appending new list
                    $("#Failedrecords").html();
                    $("#divLoading").hide();
                }
            });

        }
    } else {
        alert("Invalid filename, please select another file");
        return false;
    }

}

```

and in controller to access the file
var pic = System.Web.HttpContext.Current.Request.Files["HelpSection"];

```
        HttpPostedFileBase filebase = new HttpPostedFileWrapper(pic);
        var fileName = System.IO.Path.GetFileName(filebase.FileName);
        //var path = Path.Combine(Server.MapPath("~/App_Data/upload"), fileName);
        string destination = Request.PhysicalApplicationPath + "UploadCCIRecovery\\" + fileName;
        string strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + destination + @";Extended Properties=""Excel 12.0 Xml;HDR=YES""";
        OleDbConnection myData = new OleDbConnection(strConn);
        try
        {

            FileInfo MyFile = new FileInfo(Request.PhysicalApplicationPath);
            DirectoryInfo MyDirectory = new DirectoryInfo(Request.PhysicalApplicationPath + "UploadCCIRecovery\\");
            if (MyDirectory.Exists)
            { }
            else
            {
                System.IO.Directory.CreateDirectory(Request.PhysicalApplicationPath + "UploadCCIRecovery\\");
            }

            if (MyFile.Exists)
            {
                System.IO.File.Delete(destination);
                filebase.SaveAs(destination);
            }
            else
            {
                filebase.SaveAs(destination);
            }

```

}