$cordovaFileTransfer Upload multi image not worked ( Help me please. )

I use plugin $cordovaFileTransfer. And upload multi image incomplete.
I select image 5 image and upload but image complet 3 or 2 image.

I use Drupal is backend.

My code

$scope.submit = function() {
        console.log("Title: " + $scope.data.title + " - body: " + $scope.data.body);
       var title = $scope.data.title;
       var node_body = $scope.data.body;
       var images = $scope.images_url;
       var uid = $scope.user.uid;
       var type = $scope.data.type;
       var tel = $scope.data.tel;
       var youtube = $scope.data.youtube;

 function UploadImages(imageup,weitght,nid){
    var imageURI = imageup;
    var uri = 'http://mysite.com/upload';
    var options = new FileUploadOptions();
      options.fileKey = "file";
      options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
   var params = new Object();
       params.weight = weitght;
       params.nid = nid;

    options.params = params;
    options.chunkedMode = false;
    var ft = new FileTransfer();
    ft.upload(imageURI, uri, win, fail, options);
function win(r) {
     console.log("Code = " + r.responseCode);
     console.log("Response = " + r.response);

 function fail(error) {

          console.log('cnode:' + data);
          var nid = data;
             angular.forEach(images, function (value, key) {
                  // console.log(key + value + nid);
                  // var filename = 'file' + key;
    }, function (progress) {
        // constant progress updates

Please tell us what, how, where?

In which environment are you testing this?
What platform, iOS or Android?
Are you receiving an error? If not what’s happening?
Have you tried debugging this app?

Follow these rules: http://www.gajotres.net/help-us-help-you-how-to-ask-a-good-ionic-forum-question/

I use 2 platform, IOS and Android.
I print consolog not have error.

I think it is the issue that this code.

angular.forEach(images, function (value, key) {
                  // console.log(key + value + nid);
                  // var filename = 'file' + key;

And I think is upload first image not success and angular loop upload next image.

I can see you’re using https://github.com/apache/cordova-plugin-file-transfer plugin. It has an error callback you can use to see a problem.

// !! Assumes variable fileURL contains a valid URL to a text file on the device,
//    for example, cdvfile://localhost/persistent/path/to/file.txt

var win = function (r) {
    console.log("Code = " + r.responseCode);
    console.log("Response = " + r.response);
    console.log("Sent = " + r.bytesSent);

var fail = function (error) {
    alert("An error has occurred: Code = " + error.code);
    console.log("upload error source " + error.source);
    console.log("upload error target " + error.target);

var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
options.mimeType = "text/plain";

var params = {};
params.value1 = "test";
params.value2 = "param";

options.params = params;

var ft = new FileTransfer();
ft.upload(fileURL, encodeURI("http://some.server.com/upload.php"), win, fail, options);

Please modify upload error callback, maybe will see more information.

On the other hand, how many console log outputs are you receiving? Don’t tell me its five successful uploads?

What OS are you using on your server side? Have you tried using Fiddler (or any other similar application) to monitor data transfer between your emulator and server?

Yes, I try already. I see issue.
It’s an issue that moves the file server.

Is it works? I have this case too, only last image uploaded to server, even I tried to upload it one by one (I’m using alert to stop another loop) but it seems only last image that success

A little late to the party but I did something similar and used the Async Javascript library to push each upload task to a queue and handle them one by one (or however many you want to process in parallel). If I remember correctly, the (mobile) browsers have an issue with handle many/multiple uploads simultaneously. Anyway with the asyc queue it works just fine.