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.