ASP.NET MVC - How to upload a file with more than 5mb using ajax?

0

I'm using the following code to upload files:

HTML:

<form action="/Employee/FileUpload?UnityId=1&amp;ObjectId=1" data-ajax="true" data-ajax-failure="OnFailure" data-ajax-method="Post" data-ajax-success="OnSuccess" enctype="multipart/form-data" id="form6" method="post" class="MultiFile-intercepted"><div class="card default">
    <input multiple type="file" tabindex="-1" name="File" required title=" " autocomplete="off" maxlength="10" onchange="this.setCustomValidity('')" data-maxsize="10240" class="multi custom-file-input" accept=".bmp,.jpeg,.jpg,.pdf,.xls,.xlsx,.csv,.txt,.mp4,.mkv,.avi,.wmv,.mp3,.3gp,.doc,.docx">
    <input id="file" name="submit" role="button" type="submit" class="btn btn-primary validate-form upload-archive" tabindex="0" value="Enviar" />
</form>

JQUERY:

$(function () {
$("#form6").submit(function (event) {
    var dataString;
    event.preventDefault();
    var action = $("#form6").attr("action");
    if ($("#form6").attr("enctype") == "multipart/form-data") {

        dataString = new FormData($("#form6").get(0));
        contentType = false;
        processData = false;
    } else {

    }
    $.ajax({
        type: "POST",
        url: action,
        data: dataString,
        dataType: "json",
        contentType: contentType,
        processData: processData,
        success: function (data) {

        },
        error: function (jqXHR, textStatus, errorThrown) {

            alert("fail");
        }
    });
});

});

CONTROLLER:

    [HttpPost]
    public ActionResult FileUpload(string ObjectId, string UnityId, HttpPostedFileBase File)
    {
         .. Meu código
    }

With this code I am able to upload files up to 5mb, however when I try to load a 9mb code the code does not work, the controller is not even called and no error message is displayed.

Is there any limit for uploading files using this method?

How can I solve this problem?

    
asked by anonymous 25.10.2018 / 22:50

1 answer

1

This limitation is from asp, to change just change the parameterization in your web.config file, eg:

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="xxx" />
  </system.web>
</configuration>
    
25.10.2018 / 23:43