Cordova file upload - windows visual studio android emulator

I have written a simple cordova app using Visual studio 2015 RC. The App simply takes a photo and uploads it. Very basic and the code samples for this are everywhere online.

I have:

  • setup a blank Apache Cordova app.
  • added the plugins for camera
  • added the plugin for file
  • added the plugin for file transfer

I have added code to take a photo and then upload to a WebAPI site

For the upload i have added the following sample code from the Cordova API documentation site:

$scope.upload = function(imageURI) {
        var options = new FileUploadOptions();
        options.fileKey="file";
        options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
        options.mimeType="image/jpeg";

        var params = {};
        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);
    }

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

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

I have pointed the url for the transfer to a real url that works. Added a ng-click="upload()" to my html.

When i run this through any android emulator everything is fine until it sends the file, nothing happens.

I have used fiddler to see any requests and there is no activity at all when i try to upload.

I have checked the emulator has a network connection by opening the emulators browser and navigating around the internet, this is fine.

Any ideas why when the ft.upload occurs it does not upload at all??

In my previous experience, emulator does not work with some plugins, you may try to connect your Android phone to the pc and use the debug mode and select 'device' to try the file upload