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

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

    XMLWordPrintable

    Details

    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_33_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE
    • Pull from Repository:

      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

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Pau Ferrer
              Integrator:
              David Monllaó
              Tester:
              Simey Lameze
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/Nov/17