How to add image and post to webservice?


I’m creating a form to add new users. In this form I want to user choose your image profile, after choose the image I want to send this image to my webservice. The image is from device gallery.

I’m following this sample:
and this: How to make uploading files or images using ionicframwork or angularJS

I can’t do this works. I added cordova plugin to camera on my project: c:\myProject> cordova plugin add but does not works and when I try render throws this exception: TypeError: Cannot read property 'getPicture' of undefined

How could I do this works ?


var app = angular.module('starter');

app.factory('CameraFactory', ['$q', function($q) {

  return {
getPicture: function(options) {
var q = $q.defer(); {
// Do any magic you need
}, function(err) {
}, options);

return q.promise;


var app = angular.module("starter");
app.controller("UserCtrl", function($scope, CameraFactory){

$scope.selectImage = function() {
	    CameraFactory.getPicture().then(function(imageURI) {
	    }, function(err) {



<form name="User">
      <button ng-click="selectImage();">Imagem</button>
      <img ng-src="img/ionic.png" id="smallimage">
      <input type="text" ng-model="User.imageFile" size="30"/>

   <div class="list list-inset">
          <label class="item item-input">
              <input type="text" placeholder="Nome" ng-model="User.nome" required="true">
          <label class="item item-input">
              <input type="email" placeholder="Email" ng-model="" required="true">
          <label class="item item-input">
              <input type="password" placeholder="Senha" ng-model="User.senha" ng-minlength="8" maxlength="8"
<button type="button" class="button button-block button-energized"  
            ng-disabled="User.$invalid" ng-click="addUsuarioApp(User);">Cadastrar</button>