summaryrefslogtreecommitdiff
path: root/program/js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-08-16 12:11:21 +0000
committeralecpl <alec@alec.pl>2011-08-16 12:11:21 +0000
commitfe0cb657f1b3c0a5b097a4f7a2b670ea8c52997b (patch)
tree9c71d5b15da006ccc2289c03b4ed0e1b2a2be3bd /program/js
parentfaf10e8fec3dcd4439a3a22cb2e3877c4b622b33 (diff)
- Add client-side checking of uploaded files size
Diffstat (limited to 'program/js')
-rw-r--r--program/js/app.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/program/js/app.js b/program/js/app.js
index a4fa4194b..717b21cfe 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3253,11 +3253,21 @@ function rcube_webmail()
return false;
// get file input field, count files on capable browser
- var field = $('input[type=file]', form).get(0),
+ var i, size = 0, field = $('input[type=file]', form).get(0),
files = field.files ? field.files.length : field.value ? 1 : 0;
// create hidden iframe and post upload form
if (files) {
+ // check file size
+ if (field.files && this.env.max_filesize && this.env.filesizeerror) {
+ for (i=0; i<files; i++)
+ size += field.files[i].size;
+ if (size && size > this.env.max_filesize) {
+ this.display_message(this.env.filesizeerror, 'error');
+ return;
+ }
+ }
+
var frame_name = this.async_upload_form(form, 'upload', function(e) {
var d, content = '';
try {