index_uploads.php
";<br> print_r($_FILES);<br> echo "";
$count = count($_FILES['file']['name']);
for ($i = 0; $i $tmpfile = $_FILES['file']['tmp_name'][$i];
$filefix = array_pop(explode(".", $_FILES['file']['name'][$i]));
$dstfile = "uploads/files/".time()."_".mt_rand( ).".".$filefix;
if (move_uploaded_file($tmpfile, $dstfile)) {
echo "<script>alert('成功!');window.location.href='listdir.php';</script>" ;
} else {
echo "<script>alert('失败!');window.location.href='index_uploads.php';</script>";
}
}
uploads.php
function listdir($dirname) {
$ds = opendir($dirname);
while ($file = readdir($ds)) {
$path = $dirname.'/'. $file;
if ($file != '.' && $file != '..'){
if (is_dir($path)) {
listdir($path);
} else {
echo "
listdir.php
复制代码
download.php
下载.php
复制代码