title: How to detect the uploaded file type in angularJS
body: <p>I have an form to upload only image file using angularJS. Uploading the file is all working fine. The problem is, I want to restrict the uploaded file to be only image file and also the size of the image to be some MB. How can I achieve this using only angularJS? Below is the code</p>
  
  <pre><code>$scope.uploadFile = function(files) {
      var fd = new FormData();
      //Take the first selected file
      fd.append("file", files[0]);
  
      $http.post("logoTypesServiceStore", fd, {
          withCredentials: true,
          headers: {'Content-Type': undefined },
          transformRequest: angular.identity
      }).success( function(data) {alert(data); }).error( function(data) { alert(data)});
  
  };  
  </code></pre>
  
  <p>Below is the form to upload file.</p>
  
  <pre><code> &lt;form name="logoTypeForm" novalidate&gt;
       &lt;input type="text" name="logoType" ng-model="logoType" class="form-control" required /&gt;
       &lt;input type="file" name="file" onchange="angular.element(this).scope().uploadFile(this.files)"/&gt;
  
   &lt;/form&gt;
  </code></pre>