I have a file upload control where I can upload various types of files. After getting the file, I store it in a FormData object and make an ajax call to my controller. Everything works well with images and small .mp3 files. However, when I try to upload .mp3 files larger than 5MB, it triggers the error function.
Here is a snippet of my code :
document.getElementById('fileUploadControl').onchange = function () {
var data = new FormData();
var files = $("#fileUploadControl").get(0).files;
for (var i = 0; i < files.length; i++) {
data.append("UploadedFile" + i, files[i]);
}
var ajaxRequest = $.ajax({
url: '/Main/HandleFileUpload/',
data: data,
cache: false,
contentType: false,
processData: false,
type: "POST",
success: HandleSuccess,
error: HandleError
});
ajaxRequest.done(function (xhr, textStatus) {
});
};
<input type="file" multiple id="fileUploadControl" style="width:0px;height:0px" />
Any suggestions on how to solve this issue?