<?php
error_reporting(E_ALL);
$map = "./store/"; // Map waar alles geupload wordt
function upload_file($fTmp, $fNew) {
if(file_exists($fNew)) {
return false;
} else {
copy($fTmp, $fNew);
return true;
}
}
if(IsSet($_POST['submit'])) {
for($i = 0; $i < count($_FILES['bestand']['name']); $i++) {
if(IsSet($_FILES['bestand']['name'][$i]) && is_uploaded_file($_FILES['bestand']['tmp_name'][$i])) {
if(!upload_file($_FILES['bestand']['tmp_name'][$i], $map.$_FILES['bestand']['name'][$i])) {
$error = true;
}
}
}
if(IsSet($error)) {
echo "Mislukt!";
} else {
echo "Gelukt!";
}
} else {
if(IsSet($_POST['aantal'])) {
$aantal = $_POST['aantal'];
} else {
$aantal = 5;
}
?>
<form action="" method="post">
<input type="text" name="aantal" value="<?php echo $aantal; ?>" size="1"> <input type="submit" name="aantal_submit" value="Aantal bestanden">
</form>
<br><br>
<form action="" method="post" enctype="multipart/form-data">
<?php
for($i = 0; $i < $aantal; $i++) {
?>
Bestand <?php echo $i + 1; ?>: <input type="file" name="bestand[<?php echo $i; ?>]"><br>
<?php
}
?>
<input type="submit" name="submit" value="Uploaden">
</form>
<?php
}
?>
<?php
$map = "./store/"; // Map waar alles geupload wordt
function upload_file($fTmp, $fNew) {
return false;
} else {
return true;
}
}
if(IsSet($_POST['submit'])) { for($i = 0; $i < count($_FILES['bestand']['name']); $i++) { if(!upload_file($_FILES['bestand']['tmp_name'][$i], $map.$_FILES['bestand']['name'][$i])) {
$error = true;
}
}
}
} else {
}
} else {
if(IsSet($_POST['aantal'])) { $aantal = $_POST['aantal'];
} else {
$aantal = 5;
}
?>
<form action="" method="post">
<input type="text" name="aantal" value="
<?php echo $aantal; ?>" size="1"> <input type="submit" name="aantal_submit" value="Aantal bestanden">
</form>
<br><br>
<form action="" method="post" enctype="multipart/form-data">
<?php
for($i = 0; $i < $aantal; $i++) {
?>
Bestand
<?php echo $i + 1; ?>: <input type="file" name="bestand[
<?php echo $i; ?>]"><br>
<?php
}
?>
<input type="submit" name="submit" value="Uploaden">
</form>
<?php
}
?>