How to get an updated array / string data with all links in it?

Basically, now, every time I upload something via the upload widget I do complex manipulations to properly store image URLs inside an array/variable. And since you may want to add/remove one/remove all, you have to do complex array manipulations to keep record of all changes.

This is what your updated script looks like now.

/ get a widget reference
const widget = uploadcare.MultipleWidget("[role=uploadcare-uploader]");

// script modified by me. Added array logic to collect all possible links into one variable
let arr = new Array;

// listen to the “change” event
widget.onChange(function (group) {
// get a list of file instances
group.files().forEach(file => {
// once each file is uploaded, get its CDN URL from the fileInfo object
file.done(fileInfo => {

// script modified by me. Added array logic to collect all possible links into one variable

// this was a test piece to make sure that input field trick receives vale test.onclick = function() {
document.getElementById(“trick”).value = arr;
// Function to change content of element
// test.onclick = function() {
document.getElementById(“trick”).value = arr;

// alert(arr);

Is there a way to get an updated array of URLs every time I delete /add files?

That is my biggest pain point now.

I need output like this. Comma-separated URLs:

Hello Diego.

I’ve made a little tweak to your code. It clears and updates an array every time changes are made and stores data in the array.
OnChange triggers even if a file is removed, so it is quite handy.
Take a look at the code here and let me know if this isn’t what you’re looking for: URLs in array - CodeSandbox.

WOW, you pushed let arr = new Array; inside widget.onChange(function (group)
Got it… well, thank you :pray: I appreciate your help. You guys go above and beyond.

What should I add to this code to get file previews 140px x 140px without text, somewhere below the number of uploaded files?
Screen Shot 2022-10-18 at 9.51.44 AM

Sorry if I’m asking for too much but this would perfectly complete my UX.

Hey Diego, sorry for the delay.
I suggest you check this snippet from our docs:
Give it a try, and let us know if it’s working for you or not really.

1 Like

Thank you. I will try.

1 Like