Skip to content
Snippets Groups Projects
Commit eb266944 authored by Oliver Gasser's avatar Oliver Gasser
Browse files

Compare upload limit against biggest file

When uploading multiple files from the web interface, compare the PHP
upload limit against the largest file, not against the sum of all files.
parent 174805f5
Branches
No related tags found
No related merge requests found
...@@ -233,7 +233,8 @@ OC.Upload = { ...@@ -233,7 +233,8 @@ OC.Upload = {
data.originalFiles.selection = { data.originalFiles.selection = {
uploads: [], uploads: [],
filesToUpload: data.originalFiles.length, filesToUpload: data.originalFiles.length,
totalBytes: 0 totalBytes: 0,
biggestFileBytes: 0
}; };
} }
var selection = data.originalFiles.selection; var selection = data.originalFiles.selection;
...@@ -273,13 +274,15 @@ OC.Upload = { ...@@ -273,13 +274,15 @@ OC.Upload = {
// add size // add size
selection.totalBytes += file.size; selection.totalBytes += file.size;
// update size of biggest file
selection.biggestFileBytes = Math.max(selection.biggestFileBytes, file.size);
// check PHP upload limit // check PHP upload limit against biggest file
if (selection.totalBytes > $('#upload_limit').val()) { if (selection.biggestFileBytes > $('#upload_limit').val()) {
data.textStatus = 'sizeexceedlimit'; data.textStatus = 'sizeexceedlimit';
data.errorThrown = t('files', data.errorThrown = t('files',
'Total file size {size1} exceeds upload limit {size2}', { 'Total file size {size1} exceeds upload limit {size2}', {
'size1': humanFileSize(selection.totalBytes), 'size1': humanFileSize(selection.biggestFileBytes),
'size2': humanFileSize($('#upload_limit').val()) 'size2': humanFileSize($('#upload_limit').val())
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment