summaryrefslogtreecommitdiff
path: root/program/js
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2012-11-19 13:43:43 +0100
committerThomas Bruederli <thomas@roundcube.net>2012-11-19 13:43:43 +0100
commit271c5c976433c8318510ab16071dd3fa4cfe87c0 (patch)
tree7367312846a27ef1afeb0137f4d4f9c4935b3261 /program/js
parent19de536b86e29ed7961b2d50223106c31a436106 (diff)
Correctly handle multiple file uploads (#1488820)
Diffstat (limited to 'program/js')
-rw-r--r--program/js/app.js30
1 files changed, 18 insertions, 12 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 3d24ad921..374901a84 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -3493,20 +3493,26 @@ function rcube_webmail()
if (!form)
return false;
- // get file input field, count files on capable browser
- var i, size = 0, field = $('input[type=file]', form).get(0),
- files = field.files ? field.files.length : field.value ? 1 : 0;
+ // count files and size on capable browser
+ var size = 0, numfiles = 0;
+
+ $('input[type=file]', form).each(function(i, field) {
+ var 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++)
+ if (field.files) {
+ for (var 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;
- }
+ }
+
+ numfiles += files;
+ });
+
+ // create hidden iframe and post upload form
+ if (numfiles) {
+ if (this.env.max_filesize && this.env.filesizeerror && size > this.env.max_filesize) {
+ this.display_message(this.env.filesizeerror, 'error');
+ return;
}
var frame_name = this.async_upload_form(form, 'upload', function(e) {
@@ -3531,7 +3537,7 @@ function rcube_webmail()
});
// display upload indicator and cancel button
- var content = '<span>' + this.get_label('uploading' + (files > 1 ? 'many' : '')) + '</span>',
+ var content = '<span>' + this.get_label('uploading' + (numfiles > 1 ? 'many' : '')) + '</span>',
ts = frame_name.replace(/^rcmupload/, '');
this.add2attachment_list(ts, { name:'', html:content, classname:'uploading', frame:frame_name, complete:false });