note 48358 deleted from function.readdir by tularis
| From: | tularis@php.net | Date: | Sun, 13 May 2007 19:03:49 +0000 |
| Subject: | note 48358 deleted from function.readdir by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126532@lists.php.net to get a copy of this message | ||
Note Submitter: Anton Fors-Hurdén <atombomben at telia dot com>
----
My download function:
<?
function download($dir) {
if (isset($_GET['download'])) {
header("Content-Type: octet/stream");
header("Content-Disposition: attachment; filename=" .
basename($_GET['download']));
echo file_get_contents($_GET['download']);
} else {
if ($open = opendir($dir)) {
while (false !== ($file = readdir($open))) {
if ($file != "." && $file != "..") {
if (!is_dir($dir . $file)) {
echo "< <a href=\"?download=" . $dir . $file .
"\">" . $file . "</a><br />\n";
} else {
echo "> " . $file . "<br />\n";
echo "<div style=\"padding-left: 15px;\">";
download($dir . $file . "/");
echo "</div>";
}
}
}
closedir($open);
}
}
}
?>