This issue has been created
There are 3 updates.
 
 
XWiki Platform / cid:jira-generated-image-avatar-3dbcf474-8ed9-4c89-8008-e3fa167b24ab XWIKI-23335 Open

The upload widget throws and error after uploading an attachment

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-3aa57785-7fcb-449a-84ee-14022ee077a1 Farcasi Alexandru-Vicentiu created this issue on 25/Jun/25 13:48
 
Summary: The upload widget throws and error after uploading an attachment
Issue Type: cid:jira-generated-image-avatar-3dbcf474-8ed9-4c89-8008-e3fa167b24ab Task
Assignee: Unassigned
Components: Attachments
Created: 25/Jun/25 13:48
Priority: cid:jira-generated-image-static-major-77d60af4-cfff-4b4e-b7d3-9fb1aa4f0fdc Major
Reporter: Farcasi Alexandru-Vicentiu
Description:

When uploading a file using the upload widget, the `attachments.js` file is invoked. 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.

Steps to Reproduce

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

```xwiki
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:

```javascript
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.

 

 
 

3 updates

 
cid:jira-generated-image-avatar-3aa57785-7fcb-449a-84ee-14022ee077a1 Changes by Farcasi Alexandru-Vicentiu on 25/Jun/25 13:48
 
Version: 14.10
Description: When uploading a file using the upload widget, the `attachments.js` file is invoked. 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.

Steps to Reproduce

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

```xwiki
{ {{ \{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:

{{ ```javascript }}
{{ 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.

 
Assignee: Farcasi Alexandru-Vicentiu