Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-30008

accepted_types ignored by filemanager element

XMLWordPrintable

    • MOODLE_20_STABLE, MOODLE_21_STABLE
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • Hide

      1. Create a new file resource, upload files to it and make sure that it works
      2. Create a database resource with a picture field
      3. Make sure you cannot add something else than a picture
      4. Go to your privates files and upload a bunch of different files, make sure it works
      5. Hack the code of users/filesedit.php and change accepted_types to

      • '.jpg'
      • array('.jpg')
      • array('image')

      6. For the two first ones, make sure the only file uploadable is a jpg
      7. For the array('image') make sure you can only upload standard image files

      Show
      1. Create a new file resource, upload files to it and make sure that it works 2. Create a database resource with a picture field 3. Make sure you cannot add something else than a picture 4. Go to your privates files and upload a bunch of different files, make sure it works 5. Hack the code of users/filesedit.php and change accepted_types to '.jpg' array('.jpg') array('image') 6. For the two first ones, make sure the only file uploadable is a jpg 7. For the array('image') make sure you can only upload standard image files

      The filemanager form element does not pass the accepted_types option on to the filepicker pop-up.

      Fix:
      In lib/form/filemanager.js, function initializer:

      Find the section with all the 'this.filepicker_options.XXX = ' and add, at the end, the following line:
      this.filepicker_options.accepted_types = options.accepted_types;

      (Original test instructions follows)

      Create a filemanager element and set the 'accepted_types' to, for example, array('*.jpg')
      (e.g. in 'mod/form/post_form.php', line 88 - change "'accepted_types'=>''," to "accepted_types'=>array('.jpg'),")
      Click 'Add'
      Click 'Upload a file'
      Choose any file on your local computer that is NOT a jpeg
      Click 'Upload this file'

      Expected:
      Error message: XX filetype cannot be accepted

      Actual:
      File is accepted without complaint

            fred Frédéric Massart
            davosmith Davo Smith
            Andrew Davis Andrew Davis
            Dan Poltawski Dan Poltawski
            Rajesh Taneja Rajesh Taneja
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.