index_uploads.php
<BR><BR> <meta charset="utf-8"><BR> <title>index_uploads</title><BR><BR><body><BR> <BR> <BR> <br><BR> <BR> <br><BR> <BR> <BR><BR><BR>
uploads.php
<?php<BR> header("content-type:text/html;charset=utf-8");<BR> echo "<pre class="prettyprint linenums">";<BR> print_r($_FILES);<BR> echo "
“;
$count = count($_FILES[‘file’][‘name’]);
for ($i = 0; $i < $count; $i++) {
$tmpfile = $_FILES[‘file’][‘tmp_name’][$i];
$filef来@源gao*daima.com搞@代#码网搞gaodaima代码ix = array_pop(explode(“.”, $_FILES[‘file’][‘name’][$i]));
$dstfile = “uploads/files/”.time().”_”.mt_rand().”.”.$filefix;
if (move_uploaded_file($tmpfile, $dstfile)) {
echo “<script>alert(‘succeed!’);window.location.href=’index_uploads.php’;</script>”;
} else {
echo “<script>alert(‘fail!’);window.location.href=’index_uploads.php’;</script>”;
}
}
核心:上传首页中input的name属性是这么设置的。
用while循环上传多文件。