Fix so files size/count limit is verified (client-side) also on drag-n-drop uploads (#5940)

pull/6039/head
Aleksander Machniak 7 years ago
parent 7fc626d527
commit 5200d82381

@ -42,6 +42,7 @@ CHANGELOG Roundcube Webmail
- Fix so links over images are not removed in plain text signatures converted from HTML (#4473)
- Fix various issues when downloading files with names containing non-ascii chars, use RFC 2231 (#5772)
- Fix bug where pink image was used instead of a thumbnail when image resize fails (#5933)
- Fix so files size/count limit is verified (client-side) also on drag-n-drop uploads (#5940)
RELEASE 1.3.1
-------------

@ -5087,6 +5087,7 @@ function rcube_webmail()
this.display_message(this.env.filesizeerror, 'error');
return false;
}
if (this.env.max_filecount && this.env.filecounterror && numfiles > this.env.max_filecount) {
this.display_message(this.env.filecounterror, 'error');
return false;
@ -8973,7 +8974,8 @@ function rcube_webmail()
this.file_drag_hover(e, false);
// prepare multipart form data composition
var uri, files = e.target.files || e.dataTransfer.files,
var uri, size = 0, numfiles = 0,
files = e.target.files || e.dataTransfer.files,
formdata = window.FormData ? new FormData() : null,
fieldname = (this.env.filedrop.fieldname || '_file') + (this.env.filedrop.single ? '' : '[]'),
boundary = '------multipartformboundary' + (new Date).getTime(),
@ -9002,6 +9004,16 @@ function rcube_webmail()
// inline function to submit the files to the server
var submit_data = function() {
if (ref.env.max_filesize && ref.env.filesizeerror && size > ref.env.max_filesize) {
ref.display_message(ref.env.filesizeerror, 'error');
return;
}
if (ref.env.max_filecount && ref.env.filecounterror && numfiles > ref.env.max_filecount) {
ref.display_message(ref.env.filecounterror, 'error');
return;
}
var multiple = files.length > 1,
ts = new Date().getTime(),
// jQuery way to escape filename (#1490530)
@ -9048,6 +9060,9 @@ function rcube_webmail()
continue;
}
size += f.size;
numfiles++;
// do it the easy way with FormData (FF 4+, Chrome 5+, Safari 5+)
if (formdata) {
formdata.append(fieldname, f);

Loading…
Cancel
Save