vzhen
vzhen

Reputation: 11157

How to upload multiple files in uploadcare?

This is uploadcare question.

How to upload multiple files using uploadcare js api ?

I have this code but no luck

for (var x = 0; x < document.getElementById('files').files.length; x++) {          
    console.log(x);
    console.log(document.getElementById('files').files[x]);
    uploadcare.filesFrom('object', document.getElementById('files').files[x]);
}

Upvotes: 2

Views: 712

Answers (1)

homm
homm

Reputation: 2252

The difference between uploadcare.fileFrom and uploadcare.filesFrom is the first takes one initial object and returns exactly one uploadcare file, the second takes array of objects and returns array of uploadcare files. So you do not need to iterate files to transmit it in filesFrom.

var uploads = uploadcare.filesFrom('object', document.getElementById('files').files);
console.log(uploads);

Please, look at live example http://jsbin.com/zayuz/1/watch?html,js,output

Upvotes: 4

Related Questions