How to select multiple images and upload them ?

  • 1
  • Question
  • Updated 5 years ago
  • Answered
Hello,

I want to select multiple files and upload them. Selecting 1 file and uploading works file. I came across cordova-imagePicker plugin which allows you to select multiple images.

window.imagePicker.getPictures(
function(results) {
for (var i = 0; i < results.length; i++) {
console.log('Image URI: ' + results[i]);
}
}, function (error) {
console.log('Error: ' + error);
}
);


Where should I put the FileUpload logic ?

Thanks!
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Within the enumeration, inside the success callback function.
Photo of Abhishek Deshkar

Abhishek Deshkar

  • 48 Posts
  • 0 Reply Likes
You mean here ?

window.imagePicker.getPictures(
function(results) {
for (var i = 0; i < results.length; i++) {
var ft = new FileTransfer();
ft.upload(results[i], encodeURI("http://some.server.com/upload.php"), win, fail, options);
}
}, function (error) {
console.log('Error: ' + error);
}
);
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
Yes, that's the correct spot.