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

accepted_types ignored by filemanager element

    Details

    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:

      Description

      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

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    9/Jul/12