Hello,
All options currently that can be done are outlined in the following documentation, http://help.k2.com/onlinehelp/k2smartforms/userguide/current/default.htm#SF-ViewControls-FileAttachmentWithProgress.html.
With that in mind you can check "Show Information" that display that information of a file.
Also, if this isn't what you were looking for I would make a suggestion to https://ideas.k2.com/ to bring to the attention to the developers for a chance to see in a future release.
Hi Sharpharp1
during runtime it is possible using JS only when the file is being uploaded, once the list item is submitted you cannot get the file size
When the file is attached you can see the size in the file control:
in this case we can use some script to get the size information and transfer it to another control so you can calculate the total size
If you submit the list item then edit it, the size is no longer there
So if you are just listing the files in list view not editable, the script doesn't help here.
If the file is already stored in SQL table, have a look at this thread
http://community.k2.com/t5/K2-blackpearl/How-to-get-the-size-of-the-file-in-workflow/m-p/102317#M34049
Interesting,
@Michael - Already have the Show info ticked, its purely for display purposes and cannot be used in any form of rule or enforcement
Thanks for the ideas.k2 link as well
@Mustafa, do you have that JS handy so that i can try and transfer the file size to a control?
Perhaps i can store the File size value in a control and do an expression to total the file sizes for all the attached files (as they are added) and when clicking the submit button, check that value. If value is > 20MB, then stop transfer of the data to a list.
Regards,
Hi Sharpharp1,
See if this works for you:
1- you will need new column/Field (Size) of type Number in order to set the size for each file:
2- Transfer the following script to a datalabel when the attachment control change, configure as below
If Attachment Control IsNotEmpty
Clear Datalabel
Transfer Script to Datalabel
Else
Clear Size text box
Script:
<script>
var t = $('.file-wrapper.uploaded').attr('title');
var i = t.lastIndexOf("/");
var s = t.substring(i+1);
var bytes = s.indexOf("bytes");
var KB = s.indexOf("KB");
var MB = s.indexOf("MB");
if (bytes != -1) {
s = s.replace("bytes", "");
s =((s / 1024) / 1024);
}
if (KB != -1) {
s = s.replace("KB", "");
s = (s / 1024);
}
if (MB != -1) {
s = s.replace("MB", "");
}
parseInt(s);
if (!isNaN(s)){
$("[name='Size Text Box']").SFCTextBox('option', 'text', s);
}
</script>
Note: Needs testing and the script can be written in better ways(copied from one of my old posts on the community) :)
Find attached video(Open in IE)
Mustafa comes up with the goods yet again. Working great !!!