summaryrefslogtreecommitdiff
path: root/roundcubemail/program/js/app.js
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-08-16 12:11:21 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-08-16 12:11:21 +0000
commit9bee1c60a7f16d015c7fa01d4aeecb6c0362ee23 (patch)
tree1ee52d6bfd5be805e638a56d943b4a3a5c6d96d3 /roundcubemail/program/js/app.js
parent1edf2911b5d4f73dd1adae0f22b9122ad27fc218 (diff)
- Add client-side checking of uploaded files size
git-svn-id: https://svn.roundcube.net/trunk@5071 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/js/app.js')
-rw-r--r--roundcubemail/program/js/app.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/roundcubemail/program/js/app.js b/roundcubemail/program/js/app.js
index a4fa4194b..717b21cfe 100644
--- a/roundcubemail/program/js/app.js
+++ b/roundcubemail/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 {