简体   繁体   中英

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]);
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM