title: Downloading a file from server to client's computer
body: <p>I have a folder in my  root dir called <code>files</code>.
  This folder contains files ranging from <code>1 Kb-1 GB</code>.</p>
  
  <p>I want a php script that can simply download a file asynchronously using AJAX.</p>
  
  <p>This codes initiates download scripts when a file is clicked:</p>
  
  <p><strong>JQUERY</strong></p>
  
  <pre><code>$('.download').click(function(){
     var src =$(this).attr('src');  
     $.post('download.php',{
        src :  src //contains name of file 
      },function(data){
        alert('Downloaded!');
      });
  });
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
     $path = 'files/'.$_POST['src'];
     //here the download script must go!
  ?&gt;
  </code></pre>
  
  <p>Which would be the <strong>best, fastest and secure</strong> way to download a file? </p>