8
I am uploading Image using Jquery.
I limited the image to 2mb, but sending a larger image of 2mb shows an exception saying Maximum request size exceeded.
That’s what I did:
function fileUpload() {
$('#fileupload').fileupload();
$('#fileupload').fileupload('option', {
maxFileSize: 1024 * 1024,
autoupload: true
});
var uploadFinished = function (e, data) {
if (data.files[0].size > 2000000) { // 2mb
$.notify("Faça o upload de uma imagem de até 2MB", "danger");
jqXHR.abort();
return
}
var img = $("#inpLogoNameNew").val();
$("#imgLogo").show();
$("#imgWhite").hide();
$("#imgLogo").attr("src", (data.result.imgx64));
$("#inpLogoNameNew").val(data.result.Name);
if ($("#inpLogoNameOld").val() !== $("#inpLogoNameNew").val() &&
img !== $("#inpLogoNameNew").val() &&
img !== $("#inpLogoNameOld").val()) {
deleteLogo(img);
}
};
$('#fileupload')
.bind('fileuploaddone', uploadFinished);
}
<form id="fileupload" action="@Url.Action("UploadFiles")" method="POST" enctype="multipart/form-data">
<span id="spanUpload" class="btn btn-primary btn-sm fileinput-button"><i class="icon-plus icon-white"></i><span>Foto</span>
<input id="inpLogo" type="file" name="files[]"/>
</span>
</form>
take a look here... http://stackoverflow.com/questions/288612/how-to-increase-the-max-upload-file-size-in-asp-net
– Marciano.Andrade