title: How to upload form with image file in it, AngularJS spring
body: <p>I have this form</p>
  
  <pre><code>&lt;div class="row"&gt;
  &lt;h1 class="page-header"&gt;
      Create
  &lt;/h1&gt;
  &lt;form ng-submit="create()", enctype="multipart/form-data"&gt;
      &lt;div class="form-group"&gt;
          &lt;label&gt;Name:&lt;/label&gt;
          &lt;input type="text" ng-model="subforum.name" class="form-control" /&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label&gt;Desc:&lt;/label&gt;
          &lt;input type="text" ng-model="subforum.desc" class="form-control" /&gt;
      &lt;/div&gt;
  
      &lt;input type="file" ngf-select ng-model="subforum.icon" name="subforum.icon"
             accept="image/*" ngf-max-size="2MB" required
             ngf-model-invalid="errorFile"&gt;
      &lt;img ng-show="myForm.file.$valid" ngf-thumbnail="subforum.icon" class="thumb"&gt; &lt;button ng-click="subforum.icon= null" ng-show="subforum.icon"&gt;Remove&lt;/button&gt;
  
      &lt;button class="btn btn-success" type="submit"&gt;Create&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>``</p>
  
  <p>In my JS</p>
  
  <pre><code>.config(function($stateProvider) {
  $stateProvider.state('create', {
  
  url:'/subforum/create',
          views: {
              'main': {
                  templateUrl:'subforum/create.tpl.html',
                  controller: 'CreateCtrl'
              }
          },
          data : { pageTitle : "Create Subforum" }
  
  })
  </code></pre>
  
  <p>and</p>
  
  <pre><code>.factory('subforumService', function($resource) {
  var service = {};
  
  service.create = function (subforum, success, failure) {
          var SubForum= $resource ("/web-prog/rest/subforums");
  
          SubForum.save({}, subforum, success, failure) ;
      };
  
  .controller("CreateCtrl", function($scope, $state, subforumService) {
  $scope.create = function() {
  
  
      $scope.subforum.author = JSON.parse(localStorage.getItem ("logedUser"));
      subforumService.create($scope.subforum,
      function(returnedData) {
          $state.go("home");
  
      },
      function() {
          alert("Error creating");
      });
  };
  </code></pre>
  
  <p>I know thats not best practice to save user in LocalStorage but for now its like that. 
  On backend i have controller and in that controller i have methode:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  public ResponseEntity&lt;SubForumResource&gt; createPodforum(@RequestBody SubForumResource sentPodforum) {
  </code></pre>
  
  <p>}</p>
  
  <p>and SubForumResource is </p>
  
  <pre><code>public class PodforumResource extends ResourceSupport {
  
  private String name;
  
  private String desc;
  
  private byte[] icon;}
  </code></pre>
  
  <p>with geters and seters and everything i need.
  So when i have form without image it works without problems. But i need icon too. Im new to angularjs but need it for this project. When i try to use FormData() i dont know how to use $resource. So if someone can help me i would be thankful. This is my first prject i need to work front end so im lost.</p>