Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z uploadem plików
slwy
post
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 6.01.2009

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


Przykład zaczerpnięty z manuala PHP

Oto plik z formularzem:
  1. <form action="skrypt_upload.php" method="post" enctype="multipart/form-data">
  2. <input type="file" name="pictures[]" /></br>
  3. <input type="file" name="pictures[]" /></br>
  4. <input type="file" name="pictures[]" /></br>
  5. <input type="submit" value="Send" />
  6. </form>


a to skrypt php

  1. <?php
  2. echo '<pre>';print_r($_FILES["pictures"]);
  3. echo '</pre>';
  4. foreach ($_FILES["pictures"]["error"] as $key => $error) {
  5.    if ($error == UPLOAD_ERR_OK) {
  6.        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
  7.        $name = $_FILES["pictures"]["name"][$key];
  8.        move_uploaded_file($tmp_name, "upload/$name");
  9.    }
  10. }
  11. ?>


Problem w tym, że z 3 plików wrzuconych do formularza raz do folderu upload wgrał się tylko jeden plik, następnym razem żaden, a teraz dostaję tylko błędy:

Notice: Undefined index: pictures in C:\Inetpub\www\skrypt_upload.php on line 5

Warning: Invalid argument supplied for foreach() in C:\Inetpub\www\skrypt_upload.php on line 5


zrestartowałem serwer (Wamp 2.0) php i nie pomogło, nadal dostaję błędy. Może powinienem zmienić ustawienia serwera? brak pomysłów, proszę o pomoc...

Ten post edytował slwy 20.01.2009, 23:31:36
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
slwy
post
Post #2





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 6.01.2009

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


submit

tym razem array ma taka postac:
Kod
Array
(
     [pictures] => Array
         (
             [name] => Array
                 (
                     [0] => dn2.jpg
                     [1] => herb.jpg
                     [2] => adexpert.jpg
                 )

             [type] => Array
                 (
                     [0] => image/jpeg
                     [1] => image/jpeg
                     [2] => image/jpeg
                 )

             [tmp_name] => Array
                 (
                     [0] => C:\wamp\tmp\php72.tmp
                     [1] => C:\wamp\tmp\php73.tmp
                     [2] => C:\wamp\tmp\php74.tmp
                 )

             [error] => Array
                 (
                     [0] => 0
                     [1] => 0
                     [2] => 0
                 )

             [size] => Array
                 (
                     [0] => 33149
                     [1] => 1991
                     [2] => 41310
                 )

         )

)


ale takie 3 błędy otrzymuję (wszystkie takie same, więc wklejam jeden zestaw):
Warning: move_uploaded_file(data/dn2.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Inetpub\www\skrypt_upload.php on line 7

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php72.tmp' to 'data/dn2.jpg' in C:\Inetpub\www\skrypt_upload.php on line 7

Ten post edytował slwy 21.01.2009, 19:58:51
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 15.10.2025 - 23:24