Reputation: 31
I am developing iOs app using Phonegap, I want to upload multiple images to rails server at the same time using file uploading plugin, please anyone help with how to upload multiple images to server.
Upvotes: 3
Views: 2685
Reputation: 1516
I think If you need to upload multiple files, you couldn't upload all in same time. You need to make a loop to upload one file at a time.
For example:
//list of images URI
var items = [imgURI1,imgURI2,imgURI3];
$.each(items,function(){
uploudPhoto($(this));
});
function uploadPhoto(imageURI) {
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
var ft = new FileTransfer();
ft.upload(imageURI, encodeURI("http://some.server.com/upload.php"), win, fail, options);
}
Upvotes: 3