Hvis der skal uploades flere filer på en gang så prøv den her:
<?php
// getcwd() ->
http://dk.php.net/manual/da/function.getcwd.php define("UPLOAD_DIR", getcwd()."/"); // Hvor skal de anbringes? Husk afslut med "/"
$name = "upload"; // samme navn som i: <input type="file" name="upload[]"...
$number = 1; // filnavnet starter med en. (test1.xxx)
$username = "Brugernavn"; // filename(number).xxx
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$length = count($_FILES[$name]["name"]);
for($i = 0; $i < $length; $i++) {
$filetemp = $_FILES[$name]["tmp_name"][$i];
if (is_uploaded_file($filetemp)) {
$filename = $_FILES[$name]["name"][$i];
$filesize = $_FILES[$name]["size"][$i];
$filetype = strrchr($filename, ".");
$new_file = UPLOAD_DIR.$username.$number.$filetype;
while (file_exists($new_file)) {
$number++;
$new_file = UPLOAD_DIR.$username.$number.$filetype;
}
if (@move_uploaded_file($filetemp, $new_file)) {
echo "Uploaded: $new_file ($filesize bytes)<br>"; // udskriver uploaded filer.
}
}
}
}
?>
<form action="#" method="post" enctype="multipart/form-data">
<!-- Glem ikke [] i name="upload[]" -->
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="file" name="upload[]" size="40"><br>
<input type="submit" name="submit" value="Upload billede(er)">
</form>