title: display contents of txt file uploaded with ajax
body: <p>I've been able to get upload a .txt file to my site using ajax, but I also want to display the contents of the .txt file on my site. I'm not sure how to go about doing this. Thanks!</p>
  
  <p>here is my html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt; 
              &lt;script type="text/javascript" src="static/jquery-1.4.2.js"&gt;&lt;/script&gt;
              &lt;script type="text/javascript" src="static/jquery-ui-1.8.4.custom.min.js"&gt;&lt;/script&gt;
              &lt;script type='text/javascript' src='static/js_test.js'&gt;&lt;/script&gt;
              &lt;script type='text/javascript' src='static/jquery.form.js'&gt;&lt;/script&gt; 
  
              &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"&gt;&lt;/script&gt;
              &lt;script src="http://malsup.github.com/jquery.form.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;    
              &lt;form action="http://malsup.com/jquery/form/file-echo2.php" method="post" enctype="multipart/form-data"&gt;
                  &lt;input type="file" name="myfile"/&gt;
                  &lt;input type="submit" value="Submit File"/&gt;
              &lt;/form&gt;
  
  
  
              &lt;div class="progress"&gt;
                  &lt;div class="percent"&gt;0%&lt;/div &gt;
              &lt;/div&gt;
  
              &lt;div id="status"&gt;&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>here is my jquery</p>
  
  <pre><code>$(document).ready(function() {
  
  (function() {
  
  var bar = $('.bar');
  var percent = $('.percent');
  var status = $('#status');
  
  $('form').ajaxForm({
      beforeSend: function() {
          status.empty();
          var percentVal = '0%';
          bar.width(percentVal)
          percent.html(percentVal);
      },
      uploadProgress: function(event, position, total, percentComplete) {
          var percentVal = percentComplete + '%';
          bar.width(percentVal)
          percent.html(percentVal);
      },
      success: function() {
          var percentVal = '100%';
          bar.width(percentVal)
          percent.html(percentVal);
      },
  complete: function(xhr) {
      status.html(xhr.responseText);
  }
  }); 
  
  })();       
  
  
  
  });  
  </code></pre>
  
  <p>here is my php</p>
  
  <pre><code>&lt;?php
  foreach($_FILES as $file) {
     $n = $file['name'];
      $s = $file['size'];
     if (is_array($n)) {
        $c = count($n);
        for ($i=0; $i &lt; $c; $i++) {
           echo "&lt;br&gt;uploaded: " . $n[$i] . " (" . $s[$i] . " bytes)";
        }
     }
     else
        echo "&lt;br&gt;uploaded: $n ($s bytes)";
  }
  ?&gt;
  </code></pre>