This simple function generates a complete form and a select menu with all files of a given directory.
Download
View Source (print view)
Rating : 4.7
Views : 184
<?php
function select_files($dir) {
global $PHP_SELF;
$teller = 0;
if ($handle = opendir($dir)) {
$mydir = "<p>These are the files in the directory:</p>";
$mydir .= "<form name="form1" method="post" action="".$PHP_SELF."">n";
$mydir .= " <select name="file_in_folder">n";
$mydir .= " <option value="" selected>... n";
while (false !== ($file = readdir($handle))) {
$files[] = $file;
}
sort($files);
foreach ($files as $val) {
if ($val != "." && $val != "..") {
$mydir .= " <option value="".$val."">".$val."n";
$teller++;
}
}
$mydir .= " </select>";
$mydir .= "<input type="submit" name="Submit" value="Download">";
$mydir .= "</form>n";
closedir($handle);
}
if ($teller == 0) {
echo "No files!";
} else {
echo $mydir;
}
}
?>
php snips, unction, doc,_pdf,_rtf,_xsl__files_to_a_single_pdf_at_runtime, php script" class="neww" target="_b...', twenty_2007, paper without wood, \"php_script, yahoo_status, yahoostatus, auto loading combo box, bbcode, page link, php script" class="neww" target="_blank" title="im neuen fens, comment, page_link, rtttl_to_8_bit_source_code, buttsuckers, php-login-and-log-to-mysql.txt, upload, "php_script, send mail