title: Downloading files using jQuery, JSON, and PHP
body: <p>This is a continuation from a previous question, found here:</p>
  
  <p><a href="https://stackoverflow.com/questions/53770061/display-files-in-directory-using-php-and-jquery">Display files in directory using PHP and jQuery</a></p>
  
  <p>I am now able to display the files in a modal window as hyperlinks. What I need to do now is, instead of downloading the files, I need to display the file in a new tab.</p>
  
  <p>Here is how displayFiles.php looks:</p>
  
  <pre><code>if(isset($_POST['editpartnercode']))
  {
    $partnerCode = $_POST['editpartnercode'];
    $bookingNum = $_POST['editbooking'];
  
    $dir = "D:/CargoDocsPDFs/". $partnerCode . "/" . $bookingNum;   
    $ffs = scandir($dir);
  
    $files = array();       
    foreach($ffs as $ff)
    {               
      if($ff != '.' &amp;&amp; $ff != '..')
      {   
        array_push($files, $ff);
      }
    }
    echo json_encode($files);
  }  
  </code></pre>
  
  <p>Using all of the above, I can grab the files from the selected directory and send back over to the JavaScript side, which looks like this:</p>
  
  <pre><code>$('#resultsTable').on('click', 'tr &gt; td &gt; a.uploadDocs', function(e)
  {
    var editpartnercode = $(this).attr('data-editpartnercode');   
    var editbooking = $(this).attr('data-editbooking');   
    var directpath = "D:/CargoDocsPDFs/"+editpartnercode+"/"+editbooking+"/";
  
    $.post('process/displayFiles.php', {editpartnercode:editpartnercode,editbooking:editbooking}, function(data)
    {
      var obj = JSON.parse(data);
      $('#allFiles').empty();
      var htmlToInsert = obj.map(function (item)
      {
          return "&lt;li&gt;&lt;b&gt;&lt;a href='"+directpath+""+item+"' target='_blank'&gt;" + item + "&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;";
      });
      $('#allFiles').html(htmlToInsert);      
    });
  });
  </code></pre>
  
  <p>Using all of the above, I can return the files to the page in a modal window.</p>
  
  <p>But when I click on the link to open the file, I get the following error message:</p>
  
  <blockquote>
    <p>Not allowed to load local resource: file:///D:/filelocation/editpartnercode/bookingnum/bookingnum.jpg</p>
  </blockquote>
  
  <p>How do I fix this error?</p>