Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-23335

The upload widget throws an error after uploading an attachment

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Major
    • None
    • 14.10
    • Attachments
    • None
    • Unknown

    Description

      When uploading a file using the upload widget, the `attachments.js` file is requested and once the widget finishes uploading the file, it triggers the `wiki:html5upload:done` event, which is also handled by `attachments.js`. This script attempts to refresh the attachment section's LiveTable, even if the section is not present on the page, resulting in an error being thrown in the browser console. The upload widget requests the `attachments.js` because it receives a response from `PageName?viewer=attachments`

      Steps to Reproduce

      1. Create a new page.
      2. Add the following code to the page:

       

      {{velocity}}
      $doc.getURL()
      #set ($discard = $xwiki.ssfx.use('uicomponents/widgets/upload.css', true))
      #set ($discard = $xwiki.jsfx.use('uicomponents/widgets/upload.js', {
        'forceSkinAction': true,
        'language': $xcontext.locale
      }))
      $doc.getURL("upload")
      {{html}}
      <form action="$doc.getURL("upload")">
           ## CSRF prevention
            <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
        <input type="file" id="myFileInput" name="nameUsedToAccessTheFileOnTheServer" />
      </form>
      {{/html}}
      {{/velocity}}
      

       

       

      3. Add a JavaScript object to the page.
      4. Add the following code to the object:

       

      var targetInput = $('myFileInput');
      if(targetInput) {
        new XWiki.FileUploader(targetInput, {
          autoUpload: true,
          progressAutohide: true
        });
      } 

       

      5. Upload a file.

      Expected Output
      The file is uploaded without any error.

      Actual Output
      The file is uploaded, but an error appears in the browser console about accessing an object that is not present in the DOM.

      Attachments

        Activity

          People

            Farcasut Farcasi Alexandru-Vicentiu
            Farcasut Farcasi Alexandru-Vicentiu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: