diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-08-16 12:11:21 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-08-16 12:11:21 +0000 |
| commit | 9bee1c60a7f16d015c7fa01d4aeecb6c0362ee23 (patch) | |
| tree | 1ee52d6bfd5be805e638a56d943b4a3a5c6d96d3 /roundcubemail/program/js/app.js | |
| parent | 1edf2911b5d4f73dd1adae0f22b9122ad27fc218 (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.js | 12 |
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 { |
