]> source.dussan.org Git - nextcloud-server.git/commitdiff
Compare upload limit against biggest file
authorOliver Gasser <oliver@flowriver.net>
Tue, 12 Aug 2014 17:32:21 +0000 (19:32 +0200)
committerOliver Gasser <oliver@flowriver.net>
Tue, 12 Aug 2014 17:46:04 +0000 (19:46 +0200)
When uploading multiple files from the web interface, compare the PHP
upload limit against the largest file, not against the sum of all files.

apps/files/js/file-upload.js

index 2637d13f9bacd88bb821721bf58e1924d534accc..ff999bae4ff7edf1e5f53a0d2d07e0862fc873af 100644 (file)
@@ -233,7 +233,8 @@ OC.Upload = {
                                                data.originalFiles.selection = {
                                                        uploads: [],
                                                        filesToUpload: data.originalFiles.length,
-                                                       totalBytes: 0
+                                                       totalBytes: 0,
+                                                       biggestFileBytes: 0
                                                };
                                        }
                                        var selection = data.originalFiles.selection;
@@ -273,13 +274,15 @@ OC.Upload = {
 
                                        // add size
                                        selection.totalBytes += file.size;
+                                       // update size of biggest file
+                                       selection.biggestFileBytes = Math.max(selection.biggestFileBytes, file.size);
 
-                                       // check PHP upload limit
-                                       if (selection.totalBytes > $('#upload_limit').val()) {
+                                       // check PHP upload limit against biggest file
+                                       if (selection.biggestFileBytes > $('#upload_limit').val()) {
                                                data.textStatus = 'sizeexceedlimit';
                                                data.errorThrown = t('files',
                                                        'Total file size {size1} exceeds upload limit {size2}', {
-                                                       'size1': humanFileSize(selection.totalBytes),
+                                                       'size1': humanFileSize(selection.biggestFileBytes),
                                                        'size2': humanFileSize($('#upload_limit').val())
                                                });
                                        }