title: AngularJS Image upload using php
body: <p>I've got a problem with an image upload in AngularJS. I found this question on here: <a href="https://stackoverflow.com/questions/20487212/angularjs-file-upload-with-php">Angularjs - File upload with php</a></p>
  
  <p>As in the other question I try to use <a href="https://github.com/danialfarid/angular-file-upload" rel="nofollow noreferrer">https://github.com/danialfarid/angular-file-upload</a></p>
  
  <p>My problem is that my image that I try to upload isn't send to my php file. </p>
  
  <p>Here is the code that I use.</p>
  
  <p>PlayerController.js</p>
  
  <pre><code>angular.module('lax').controller('PlayerController', function($scope, $http, $upload) {
  
  $scope.onFileSelect = function($files) {
      $scope.message = "";
      for (var i = 0; i &lt; $files.length; i++) {
          var file = $files[i];
          console.log(file);
          $scope.upload = $upload.upload({
              url: 'php/upload.php',
              method: 'POST',               
              file: file
          }).success(function(data, status, headers, config) {
              $scope.message = data;                
          }).error(function(data, status) {
              $scope.message = data;
          });
      }
  };
  });
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;div ng-show="newplayer.functie == 'update'"&gt;
                          &lt;h3&gt;Profile Pic&lt;/h3&gt;                         
                          &lt;div&gt;
                              &lt;input type="file" name="image" id="image" ng-file-select="onFileSelect($files)"&gt;
                              &lt;br/&gt;
                              &lt;span class="errorMsg"&gt;{{ message}}&lt;/span&gt;
                          &lt;/div&gt;
  
                      &lt;/div&gt;
  </code></pre>
  
  <p>upload.php</p>
  
  <pre><code>&lt;?php
      if(isset($_FILES['image'])){    
          $errors= array();        
          $file_name = $_FILES['image']['name'];
          $file_size =$_FILES['image']['size'];
          $file_tmp =$_FILES['image']['tmp_name'];
          $file_type=$_FILES['image']['type'];   
          $file_ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
          $extensions = array("jpeg","jpg","png");        
          if(in_array($file_ext,$extensions )=== false){
               $errors[]="image extension not allowed, please choose a JPEG or PNG file.";
          }
          if($file_size &gt; 2097152){
              $errors[]='File size cannot exceed 2 MB';
          }               
          if(empty($errors)==true){
              move_uploaded_file($file_tmp,"../../Img/PlayerAvatar/".$file_name);
              echo $fname . " uploaded file: " . "images/" . $file_name;
          }else{
              print_r($errors);
          }
    }
      else{
          $errors= array();
          $errors[]="No image found";
          print_r($errors);
  }
  ?&gt;
  </code></pre>
  
  <p>So the "if(isset($_FILES['image']))" gives false as a result. I'm new to stackoverflow and angularJS so sorry for any noob questions.</p>