How to reset widget when upload is complete?

To remove a file from the widget, after you’ve finished uploading, call the widget’s value() method with null:

uploadcare.Widget('#file-uploader').value(null);

Also, users can clear the widget manually. To enable the reset button, enable the clearable option in widget settings. For more information, see Clearable.

How would this work for the new block-based File Uploader? I do not see any corresponding option in the configs.

Hello.

There’s an undocumented API method you can use to clear the uploader from uploaded files:

const ctx = document.querySelector('lr-upload-ctx-provider');
ctx.uploadCollection.clearAll();

Give it a try an let me know if it worked for you.

Best regards.

That worked. Thanks!

1 Like