login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Upload systemen > Uploader (meerdere bestanden)

Uploader (meerdere bestanden)

Auteur: XenoX - 19 augustus 2004 - 16:37 - Gekeurd door: Dennisvb - Hits: 15442 - Aantal punten: 3.17 (9 stemmen)





Dit script laat je zelf instellen hoeveel bestanden je wilt uploaden en maakt daar het aantal invoer schermpjes voor.

Code:
upload.php:
  1. <?php
  2.  
  3. $map = "./store/"; // Map waar alles geupload wordt
  4.  
  5. function upload_file($fTmp, $fNew) {
  6. if(file_exists($fNew)) {
  7. return false;
  8. } else {
  9. copy($fTmp, $fNew);
  10. return true;
  11. }
  12. }
  13.  
  14. if(IsSet($_POST['submit'])) {
  15. for($i = 0; $i < count($_FILES['bestand']['name']); $i++) {
  16. if(IsSet($_FILES['bestand']['name'][$i]) && is_uploaded_file($_FILES['bestand']['tmp_name'][$i])) {
  17. if(!upload_file($_FILES['bestand']['tmp_name'][$i], $map.$_FILES['bestand']['name'][$i])) {
  18. $error = true;
  19. }
  20. }
  21. }
  22.  
  23. if(IsSet($error)) {
  24. echo "Mislukt!";
  25. } else {
  26. echo "Gelukt!";
  27. }
  28. } else {
  29. if(IsSet($_POST['aantal'])) {
  30. $aantal = $_POST['aantal'];
  31. } else {
  32. $aantal = 5;
  33. }
  34.  
  35. ?>
  36. <form action="" method="post">
  37. <input type="text" name="aantal" value="<?php echo $aantal; ?>" size="1">&nbsp;<input type="submit" name="aantal_submit" value="Aantal bestanden">
  38. </form>
  39. <br><br>
  40. <form action="" method="post" enctype="multipart/form-data">
  41. <?php
  42. for($i = 0; $i < $aantal; $i++) {
  43. ?>
  44. Bestand <?php echo $i + 1; ?>: <input type="file" name="bestand[<?php echo $i; ?>]"><br>
  45. <?php
  46. }
  47. ?>
  48. <input type="submit" name="submit" value="Uploaden">
  49. </form>
  50. <?php
  51. }
  52. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (9)
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.022s