protect files download in a folder on server &.htacess visible
I am using a php file code as below to list out the files in a directory
form which user will check the required files and download them as a zip
file
I have 2 issues
1) How to protect files from Direct download using url i want the files to
be downloaded only with form action that is through downloadlist.php (if i
keep denyall in .htaccess , the downloaded file is corrupted )
2) this code also shows .htaccess in the list for download ( so i doubt is
their a way to only list Docs,Xls,pdf's)
i can provide downloadlist.php if required
<?php
function listDir($dirName)
{
?><form name="filelist" action="downloadList.php" method="POST"><?php
echo "\n";
if ($handle = opendir($dirName)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { ?> <input
type=checkbox name="file[]" value="<?php echo
"$file";?>"><?php echo "$file"; ?><br><?php echo "\n";
}
}
closedir($handle);
}
?><br><input type="submit" name="formSubmit" value="Zip and download"
/></form><?php
}
listDir('./fold'); ?>
No comments:
Post a Comment