index_uploads.php
Copy Code code as follows:
<meta charset= "Utf-8" >
<title>index_uploads</title>
<body>
<form action= "uploads.php" method= "post" enctype= "Multipart/form-data" >
<input type= "File" Name= "file[]" >
<br>
<input type= "File" Name= "file[]" >
<br>
<input type= "Submit" value= "uploads" >
</form>
</body>
uploads.php
Copy Code code as follows:
<?php
Header ("Content-type:text/html;charset=utf-8");
echo "<pre>";
Print_r ($_files);
echo "</pre>";
$count = count ($_files[' file '] [' name ']);
for ($i = 0; $i < $count; $i + +) {
& nbsp; $tmpfile = $_FILES[' file ' [' Tmp_name ' [$i];
$filefix = Array_ POPs (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> ';
}
}
Core:<1> upload the Name property of input in the home page is set.
<2> use a while loop to upload multiple files.