I am not sure why I am getting the following error:
Not allowed to load local resource: file:///D:/CargoDocsPDFs/0000024606//NAM3112358.pdf
I am using the function below to create a table with links to pdf files a user can simply click to download:
<?php
function return401KDocs()
{
$dir = "D:/CargoDocsPDFs/0000024606/";
$ffs = scandir($dir);
echo "<table class='table table-bordered display nowrap'>";
echo "<thead>";
echo "<tr>
<th style='width:300px;'>File Name</th>
<th style='width:100px;'>Upload Date</th>
<th style='width:25px;'>File Size</th>
<th style='width:100px;'>Delete</th>
</tr>";
echo "</thead>";
echo "<tbody>";
foreach($ffs as $ff)
{
if($ff != '.' && $ff != '..' && preg_match('#(pdf|doc|docx|xls|xlsx|PDF)$#',$ff))
{
$filesize = filesize($dir . '/' . $ff);
echo "<tr><td><a download href='$dir/$ff'>$ff</a></td><td>" .
date('m.d.y - g:i A', filemtime($dir . '/' . $ff)) .
"</td><td>" . round(($filesize / 1024), 2) . " kb</td>
<td><a href='#' class='delete401KFile' data-file='".$ff."'>Delete</a></td></tr>";
}
}
echo "</tbody>";
echo "</table>";
}
?>
Using the above function prints out a table, and the available files are links that a user should be able to click to download the file. But I am prohibited by the subject error message.
I found this link: jQuery Not allowed to load local resource
But I cannot use that link as it is in regards to using an AJAX call. I am trying to accomplish this task with PHP.
I made an answer coz wasn't able to comment because of the points, so please don't negative vote.
You shouldn't load files off a local filesystem. You need to have it hosted with your app and load it off the web server.
You will never be able to directly display files on the client that are in your storage folder (C or D drives). The only thing browsers can actually get at are:
So, you would need to store your files somewhere in the public folder (of the server)
You can get some help with this link: https://webmasters.stackexchange.com/questions/53870/cannot-load-local-resource