Just thought we'd share this Scriptlet we got working for checking document size before it is uploaded to AwareIM. I.e. the size is checked when the document is selected.
You can put it in the Advance Initialization Script of the Form and change the size and message. Works like a charm for us:
for (var i = 0; i < widgets.length; ++i) {
if (widgets[i].type == "upload") {
widgets[i].config.select = function onSelect(e) {
$.each(e.files, function (index, value) {
if (value.size > 5000000) {
e.preventDefault();
alert("Document too large (>5mb) - please resize the document and try again.");
}
});
};
}
}
Hein Hanekom & Werner Hanekom
Sinov8.net
AwareIM Version 5.9 | 6.0 | 7.0 | 7.1 (Windows EC2 R2012 & MySQL)
Thanks for sharing. I believe I can say for a fact that my server has been brought down several times by one or more users uploading a large document. Everyone should deploy this script where you have document uploads. Since deploying a similar solution, I have had no problems.