Hi everyone,
We are thinking about how to separate the attachment file size from SharePoint size imitation. For example, The SharePoint maximum upload file size is 50 MB but I need to control the attachment size to 5MB in Nintex Form. However, I cannot find any OOTB method to control the file size. Can anyone suggest other ways to achieve it?
Solved! Go to Solution.
I guess you mean Mark Altman's script..
I've tried that script and noticed there is missing one closing brace there.
as well check for case when there is not any file attached needed little extend.
finally I reverted what value is returned in what case so that it is easier to use in validation rules
try following version
function IsFileSizeExceeded(maxSizeInMB) {
var isValid=false;
for ( var i=0; i<NWF$('input[type=file]').length; i++ ) {
if(NWF$('input[type=file]')[i].files.length>0 && NWF$('input[type=file]')[i].files[0]!==null && NWF$('input[type=file]')[i].files[0]!==undefined) {
if(NWF$('input[type=file]')[i].files[0].size>(maxSizeInMB*1048600)) {
var sizeInMB = Math.round(NWF$('input[type=file]')[i].files[0].size / 10486) / 100; // # MB with two decimal places
isValid=true;
alert("The maximum file size is "+maxSizeInMB+"MB, but the file " + NWF$('input[type=file')[i].files[0].name + " is " + sizeInMB + "MB. Please reduce the file size before uploading.");
break;
}
}
}
return isValid;
}
I used it as follows
Thanks @marian hatala. You save me.
This script is for 1mb, where or how change a 15mb for example???
Thanks
Federico MS.
max allowed size is determined by input paramter of IsFileSizeExceeded() function.
Thanks.
FMS.
This works great. but it seems that it validate the size of each uploaded file.
in my case I need to know the total of all uploaded files in one attachment control. the reason is to attach them in emails.
any help?. I'm no good with JS.
kindly, vote for this update: Validate the max size of attachment control – Customer Feedback for Nintex