Limit for uploading files

3

I have a project in Asp Net MVC .NET Framework 4 as follows:

View:

<div class="file-content">
    <label class="custom-file-upload">
          <input type="file" id="importar-arquivos" multiple accept=".pdf" name="arquivo" required />
          <span class="ui-icon ui-icon-circle-arrow-n file-icon"></span> Escolher Arquivos
    </label>
    <br />
    <span id="file-selected">​​</span>
</div>

<div class="options-content">
    <img src="../Images/save-send.png" id="file-enviar" class="icon-action" title="Enviar" />
    <img src="../Images/btnerror.png" id="file-cancelar" class="icon-action" title="Cancelar" />
</div>

<script>
    (function () {
        $("#file-enviar").on("click", function () {
            try {
               var fileImput = $("#importar-arquivos");
                var arquivos = fileImput.get(0).files;

                if (arquivos.length > 0) {

                    prepararPDF(arquivos);

                } else {
                    alert("Selecione os arquivos para enviar!");
                }
            } catch (ex) {
                console.error("Erro ao enviar arquivo!", ex);
            }
        });

        function prepararPDF(arquivos) {
            var paramsData = new FormData();
            for (var i = 0; i < arquivos.length; i++) {
                paramsData.append("files", arquivos[i]);
            }

            enviarPDF(paramsData);
        }

        function enviarPDF(paramsData) {
            $.ajax({
                beforeSend: function () {
                    IniciaLoad();
                },
                complete: function () {
                    FinalizaLoad();
                },
                contentType: false,
                processData: false,
                dataType: "json",
                type: "POST",
                url: "minhaURL",
                data: paramsData,
                success: function (data) {
                    console.debug("data", data);
                },
                fail: function () {
                    alert("Falhou!");
                },
                error: function () {
                    alert("Erro de Conexão");
                }
            });
        }

    })();
</script>

Controller:

[HttpPost]
public ActionResult MinhaAction(HttpPostedFileBase[] files)
{
   return Json(files.Length, JsonRequestBehavior.AllowGet);
}

When testing small files did not I got no problem, but when trying to upload multiple large files, I got the following error:

  

HTTP Error 404.13 - Not Found
  The request filtering module is configured to deny a request that exceeds the requested content size.


  • The problem is the number of files , the size of each of them or sum the size of all files ?
  • What is the default limit for quantity of files and size of them?
  • How can I set a higher limit?
  • asked by anonymous 30.09.2016 / 14:52

    3 answers

    4

    There are two settings to be modified .

    maxRequestLength indicates the maximum size of an upload supported by ASP.NET maxAllowedContentLength specifies the maximum content size of a request supported by IIS.

    Expand the acceptable file size by setting the following entry in the web.config file:

      

    web.config

     <system.web> 
         <httpRuntime maxRequestLength="104857600"/> 
     </system.web>
     <system.webServer>
        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="104857600"/>
          </requestFiltering>
        </security>
      </system.webServer>
    

    Where maxAllowedContentLength is measured in bytes, whose default value is 30000000 , (approximately 28.6MB).

    The maximum number of sequential files to send is 4,294,967,295 (NTFS) or by the sum of their largest sizes the multipart header , whichever is less.

    If the problem persists, it may be that the settings made in the web.config file can be overridden by definitions present in both applicationhost.config and machine.config .

    If you have access to these, make sure that the overrideModeDefault tails property of the corresponding sections is set to Allow , as in the following example:

      

    machine.config

    <requestFiltering overrideModeDefault="Allow">
        <requestLimits maxAllowedContentLength="104857600"/>        
    </requestFiltering>
    

    There is no way, as far as I know, to override these settings if you do not have access to the corresponding configuration file.

    Font .

        
    30.09.2016 / 15:02
    1

    No httpRuntime within your web.config you can specify maxRequestLength that will determine the maximum size of your requests.

      

    The maximum size of requests, in kilobytes. The default size is   4096 KB (4 MB).

    Font

    There are other questions and answers pertaining to the subject.

    link

    link

        
    30.09.2016 / 14:58
    0

    The default limit for the size of each file is 4mb or 4096 KB in ASP.NET

    To set the size for the entire application, simply add the following to your web.config:

    <configuration>
      <system.web>
        <httpRuntime maxRequestLength="xxx" />
      </system.web>
    </configuration>
    

    The xxx value you replace with the maximum value you want to allow in kb.

        
    30.09.2016 / 14:59