Doubt about how to upload and download files from a server


#1

I rather doubt on this issue, I have held several methods to upload a file (in this case a picture taken with the camera device) but I could not get it to work.

I followed the correct answer of this post: here but can not get it to work. This is the error I get.

Error: undefined is not a constructor (evaluating 'new FileTransfer')

var server = URL_BASE+'addView/';

var trustAllHosts = true;

var ftOptions = new FileUploadOptions();
ftOptions.fileKey = 'file';
ftOptions.fileName = $scope.imagen.substr($scope.imagen.lastIndexOf('/') + 1);
ftOptions.mimeType = 'image/jpeg';
ftOptions.httpMethod = 'POST';

    $cordovaFileTransfer.upload(encodeURI(server), $scope.imagen, ftOptions, trustAllHosts)
      .then(function(result) {
      console.log('success: ' + angular.toJson(result));
      },
      function(err) {
      // Error
        console.log('error: ' + err);
      },
      function (progress) {
      // constant progress updates
    });