Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP] Multiupload zdjęć
ayo1001
post
Post #1





Grupa: Zarejestrowani
Postów: 74
Pomógł: 1
Dołączył: 29.03.2013

Ostrzeżenie: (0%)
-----


Cześć,

Mam taki kod:

  1. <form action="test.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
  2. <p>Tytuł :
  3. <label for="title"></label>
  4. <input type="text" name="title" id="title" />
  5. </p>
  6. <p>Zdjęcie1:&nbsp;
  7. <label for="image1"></label>
  8. <input type="file" name="image1" id="image1" />
  9. </p>
  10. <p>Zdjęcie2 :&nbsp;
  11. <label for="image2"></label>
  12. <input type="file" name="image2" id="image2" />
  13. </p>
  14. <p>Zdjęcie3 :&nbsp;
  15. <label for="image3"></label>
  16. <input type="file" name="image3" id="image3" />
  17. </p>
  18. <p>Treść :</p>
  19. <label for="contents"></label>
  20. <textarea name="content" cols="100" rows="15" id="content"></textarea>
  21. </p>
  22. <p>
  23. <input type="submit" name="button" id="button" value="Zatwierdź" />&nbsp;
  24. <br><br><br><br><br><br><br>
  25. </form>



  1. <?php
  2. $name1 = $_FILES["image1"]["name"];
  3. $tmp = $_FILES["image1"]["tmp_name"];
  4. $name1 = "./images/test/".$name1;
  5. $moveResult = move_uploaded_file($tmp, $name1);
  6.  
  7. $name2 = $_FILES["image2"]["name"];
  8. $tmp = $_FILES["image2"]["tmp_name"];
  9. $name2 = "./images/test/".$name2;
  10. $moveResult = move_uploaded_file($tmp, $name2);
  11.  
  12. $name3 = $_FILES["image3"]["name"];
  13. $tmp = $_FILES["image3"]["tmp_name"];
  14. $name3 = "./images/test/".$name3;
  15. $moveResult = move_uploaded_file($tmp, $name3);
  16.  
  17. $post_title=$_POST['title'];
  18. $post_image1=$_FILES["image1"]["name"];
  19. $post_image2=$_FILES["image2"]["name"];
  20. $post_image3=$_FILES["image3"]["name"];
  21. $post_content=$_POST['content'];
  22. ?>


Jak można ten kod przerobić, żeby po dodaniu 3 zdjęć było można dodać kolejne lub "Jeżeli nie dodałem zdjęcia to nie pojawia się na stronie - w tym momencie jak się nic nie wrzuci to jest tylko ramka..."
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 23:15