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 performing tests with few small files nay got no problem, but while trying to send multiple larger files then 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 amount of files, the size of each theirs or the sum of the size of all files?
- What is the default limit for amount of archives and size theirs?
- How can I set a higher limit?
Thank you so much for sharing your wisdom @Onosendai , but I want to get even more! What would be the default file size limit? What file limit (quantity) can I submit in a single request?
– Jedaias Rodrigues
@Jedaiasrodrigues Answers added to the answer. =)
– OnoSendai
from what I understood the 4,294,967,295 files would be the limit for an NTFS directory, this limit also applies for a POST as I am doing? I believe the amount of files is more related to the
maxAllowedContentLength
as you well quoted... I’m sure?– Jedaias Rodrigues
@Jedaiasrodrigues correct. Limiting the amount of files is only relevant for NTFS.
– OnoSendai