I am trying to make a script that reads a folder and echos a link for each file in the folder into a downloadable file.
I am having a hard time getting the download fuction to work in the for loop.
Here is the script with just a link to the file.
Any help appreciated!
<?php
$path = ".";
$types = "[]";
$all = opendir($path);
$theFiles = array();
while ($file = readdir($all)) {
if (!is_dir($location.'$path'.$file) and $file <> ".." and $file <> ".") {
if (preg_match($types,$file)) {
array_push($theFiles,$file);
}
}
}
echo '<ul>
';
$arlength = count($theFiles);
for ($i=0; $i<$arlength; $i++) {
echo ' <li><a href="'.$path.'/'.$theFiles[$i].'">'.$theFiles[$i].'</a></li>
';
}
echo '</ul>';
?>