← Back to team overview

mahara-contributors team mailing list archive

[Bug 1904946] Re: Filebrowser - Uploading number of files exceed limit give never-ending spinner

 

Actually something like this
+++ b/htdocs/artefact/file/js/filebrowser.js
@@ -112,6 +112,13 @@ var FileBrowser = (function($) {
             $('#' + self.id+'_upload_messages').append($('<div>', {'class':'alert alert-danger', 'text':get_string('youmustagreetothecopyrightnotice')}));
             return false;
         }
+console.log('number of files ' + $('#' + self.id + '_userfile')[0].files.length);
+        if ($('#' + self.id + '_userfile')[0].files.length > 20) {
+            var errmsg = $('<div>', {'class':'alert alert-danger'});
+            errmsg.html(get_string_ajax('fileuploadtoomany', 'error', 20));
+            $('#' + self.id+'_upload_messages').append(errmsg);
+            return false;
+        }
         if (!($('#' + self.id + '_userfile')[0].files[0].size < globalconfig.maxuploadsize)) {
             var errmsg = $('<div>', {'class':'alert alert-danger'});
             errmsg.html(get_string_ajax('fileuploadtoobig', 'error', globalconfig.maxuploadsizepretty));
diff --git a/htdocs/lang/en.utf8/error.php b/htdocs/lang/en.utf8/error.php
index 05d4fcb99a..49e27c2156 100644
--- a/htdocs/lang/en.utf8/error.php
+++ b/htdocs/lang/en.utf8/error.php
@@ -163,5 +163,6 @@ $string['updatesitetimezone'] = 'The time zone for the site now needs to be set
 $string['pluginnotactive1'] = 'The plugin "%s" is not enabled. Please got to "Administration" →  "Extensions" →  "Plugin administration" to enable it.';
 
 $string['fileuploadtoobig'] = 'The file upload is too big as it is bigger than "%s"';
+$string['fileuploadtoomany'] = 'Too many files are being uploaded at once. Maximum to upload at once are "%s"';
 $string['sideblockmenuclash'] = 'The sideblock name "%s" is already in use. Please choose a different one.';
 $string['isolatedinstitutionsremoverules'] = 'We have hidden %s access rules due to isolated institutions being in effect. The hidden rules will be removed once the form is saved.';


Where the two '20' values should be a globalconfig.maxuploadnumber  passed in from htdocs/lib/form/elements/filebrowser.php as $config['maxuploadnumber']

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1904946

Title:
  Filebrowser - Uploading number of files exceed limit give never-ending
  spinner

Status in Mahara:
  In Progress

Bug description:
  In the /etc/php/7.2/apache2/php.ini files it states max_file_uploads =
  20

  Trying to upload more than max_file_uploads in one request will cause
  the wrong error messages to appear.

  Reproduce:
  1. Create -> Files -> Browse
  2. Select 21 files and click 'ok'

  Expect:
  - Info messages appear for each upload-file saying it's being uploaded
  - Once uploaded, the matching info message turns to a temp success message (green) and disappears
  - All the selected files have been uploaded and appear in the user's list of files

  Actual:
  - Info messages appear for each upload-file saying it's being uploaded
  - The the 21st file does not get uploaded due to the restriction but the user doesn't know about the restriction
  - The info message matching the 1st file in the selected upload-list stays forever spinning.

  Notes:
  - Even if a message stays spinning forever because there was a file(s) that didn't get uploaded, the text in the message should match the non-uploaded file
  - There should be a message informing the user of the max number of files they're allowed to upload at any one time
  - The filebrowser could prevent the user from selecting more than the max_file_uploads number

  Todo:
  - (Maximum upload size: [SPACE AVAILABLE]MB, maximum file uploads: [VALLUE FROM PHP.INI FILE], check what happens when PHP.ini doesn't have a value for max_file_uploads)
  - Error message: replace info message with an error message for the same file.
  - (nice to have)check upload_validate js function to check if we can alert the user before files are uploaded

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1904946/+subscriptions


References