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

Allow Cross-Origin requests in webservice/upload.php (backport of MDL-60302)

    XMLWordPrintable

Details

    • MOODLE_33_STABLE
    • MOODLE_32_STABLE, MOODLE_33_STABLE
    • Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a Token in the mobile app service for one user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Unzip the attached zip file
      4. Edit the unzipped js/script.js file, look for the line starting by oXHR.open('POST', and change the Moodle URL with your one, replace the token with the token generated in step 2
      5. Open the unzipped index.html in a browser
      6. Upload a file via the index.html form and check that you receive a JSON response where you will be able to find attributes like the draft itemid, filename, contextid, userid and other values
      7. If you try to upload a file without the patch applied you will get an error
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for one user: Click on Site administration ► Plugins ► Web services ► Manage tokens Unzip the attached zip file Edit the unzipped js/script.js file, look for the line starting by oXHR.open('POST', and change the Moodle URL with your one, replace the token with the token generated in step 2 Open the unzipped index.html in a browser Upload a file via the index.html form and check that you receive a JSON response where you will be able to find attributes like the draft itemid, filename, contextid, userid and other values If you try to upload a file without the patch applied you will get an error

    Description

      It should be completely safe to apply MDL-60302 in previous Moodle versions.

      This functionality if especially handy for uploading files via AJAX in webapps.

      Attachments

        Issue Links

          Activity

            People

              jleyva Juan Leyva
              jleyva Juan Leyva
              Pau Ferrer Pau Ferrer
              David Monllaó David Monllaó
              Simey Lameze Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                13/Nov/17