I do a scandir of a specific dir and I display the file names in a table. Now I want to make every file downloadable but I am not sure how to do this.
here is where I print the filenames in a table:
<tbody>
<?php
$i = 0;
foreach ($files as $file) {
$i++;
echo "<tr><th scope='row'>$i</th><td>$file</td><td><i class=\"fa fa-download\" aria-hidden=\"true\"></i></td></tr>";
}
?>
</tbody>
I was thinking of using a function or php file with something like this
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=file.zip");
header("Pragma: no-cache");
header("Expires: 0");
readfile("file.zip");
but I am not sure how to inject the filename and content type in my function of php file
Any help is greatly appreciated!
Many thanks in advance!