title: Print out file content after upload, AngularJS
body: <p>EDIT: I solved it. I wrote:</p>
  
  <pre><code>$scope.result = data
  </code></pre>
  
  <p>In the success-area.</p>
  
  <p>I have a form that you can upload files. I'm using angular-file-upload model that I've found at github: <a href="https://github.com/danialfarid/angular-file-upload" rel="nofollow">https://github.com/danialfarid/angular-file-upload</a></p>
  
  <p>The upload works perfect. However, after I've uploaded the file, I want to return the file contents, and print it out at the site, but I don't now how to bind the file to the $scope.</p>
  
  <p>Here is my controler:</p>
  
  <pre><code>as.controller('Marketing', function($scope, $http, $upload)
      {
          $scope.onFileSelect = function($files) {
              var file = $files[0];
              if (file.type.indexOf('image') == -1) {
                  $scope.error = 'image extension not allowed, please choose a JPEG or PNG file.'            
              }
              if (file.size &gt; 2097152){
                  $scope.error ='File size cannot exceed 2 MB';
              }     
              $scope.upload = $upload.upload({
                  url: 'partials/result.php',
                  data: {},
                  file: file,
              }).success(function(data, status, headers, config) {
                  // file is uploaded successfully
                  console.log(data);
              });
          }
      });
  </code></pre>
  
  <p>Here is my PHP:</p>
  
  <pre><code>$filename = $_FILES['file']['tmp_name'];
  
  if(($handle = fopen($filename, "r")) !== FALSE) {
      while(($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
          $num = count($data);
          echo "&lt;p&gt; $num fields in line $row: &lt;br/&gt;&lt;/p&gt;\n";
          $row++;
          for($c = 0; $c &lt; $num; $c++) {
              echo $data[$c] . "&lt;br/&gt;\n";
          }
      }
      fclose($handle);
  }
  </code></pre>
  
  <p>And here is my HTML:</p>
  
  <pre><code>&lt;div ng-controller="Marketing"&gt;
  &lt;form class="well form-search" enctype="multipart/form-data"&gt;
      &lt;input type="file" name="image" ng-file-select="onFileSelect($files)" &gt;
  &lt;/form&gt;
  
  &lt;pre ng-model="result"&gt;
      {{result}}
  &lt;/pre&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>As you can see, I want to bind the content to the $scope.result.</p>