Bonjour a tous
je suis en train de faire un code pour uploader plusieurs photos,

pour le moment au moment de l'insertion il me rentre une photo par entrée, il me met la photo1 sur une entrée, la photo2 sur une autre entrée et idem pour la 3.

je suis sur de faire une erreur mais apres pas mal de recherche et peu de connaisse je suis dans le flou ....

j'aimerais qu'il me rentre la photo1 dans le champ photo1,la photo2 dans le champ photo2 sur la meme entrée

voici le code complet
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
require('connect.php');
 
if(!empty($_FILES))
{
       foreach($_FILES["photo"]["name"] as $key => $name)
 
       {
 
 
 
       // Définition des variables
      $photo = $_FILES['photo'];
      $photo_name = $photo['name'][$key];
      $file_tmp =$_FILES['photo']['tmp_name'][$key];
      $file_type=$_FILES['photo']['type'][$key];   
      $ext = strtolower(substr(strrchr($_FILES["photo"]["name"][$key],'.'),1));
      $ext_aut = array('jpg','jpeg','png','gif');
      $max_size = 1048576;
      $size = $photo['size'][$key];
 
      //si input vide on passe
      if(!$_FILES["photo"]["name"][$key]) continue;
 
 
 
 
    //test de l'extension
 
         if(!in_array($ext, $ext_aut)) //Si l'extension n'est pas dans le tableau
           {
             $erreur = 'Vous devez uploader un fichier de type png, gif, jpg, jpeg';//on créer une variable erreur
           }
 
    // test de la taille
 
         if($size > $max_size)//Si La taille est trop grande  
           {
              $erreur = 'Le fichier est trop gros...';// on définit un erreur pour la taille
           }
 
         if(!isset($erreur))//Si il n'y a pas d'erreur
 
    //traitement de la photo
           {
          $path_to_image = 'photos/fullsize/';
          $path_to_min = 'photos/mini/';
    //renommage de la photo
          $filename = sha1(uniqid($photo_name[$key])); 
 
          $source = $photo['tmp_name'][$key];
          $target = $path_to_image . $filename. '.'. $ext;
   // deplacement de la photo dans fullsize
          move_uploaded_file($source,$target);
 
          if($ext == 'jpg' || $ext == 'jpeg') {$im = imagecreatefromjpeg($path_to_image.$filename.'.'.$ext);}
          if($ext == 'png') {$im = imagecreatefrompng($path_to_image.$filename.'.'.$ext);}
          if($ext == 'gif') { $im = imagecreatefromgif($path_to_image.$filename.'.'.$ext);}
          $ox = imagesx($im);
          $oy = imagesy($im);
 
    // reduction de la photo
        $nom_image = $filename.$key.'.'.$ext;
        $nx = 80;
        $ny = floor($oy *($nx/$ox));
        $nm = imagecreatetruecolor($nx,$ny);
 
        imagecopyresized($nm, $im, 0,0,0,0, $nx,$ny,$ox,$oy);
 
        imagejpeg($nm, $path_to_min.$filename.'.'.$ext);
 
 
    // insertion dans la base de donnée
        $req = $bdd->prepare('INSERT INTO upload(photo'.$key.') VALUES(:photo)');
        $req->execute(array('photo'=>$nom_image));
        $req->closeCursor();
 
        }
      }
 
 
 
}
 
?>
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="style.css" media="all" />
    <title></title>
</head>
<body>
    <div id="content">
 
 
 
        <?php if(isset($erreur)):?>
 
        <div class="error"><?php echo $erreur;?></div>
 
        <?php endif;?>
 
        <form action="" enctype="multipart/form-data" method="post">
 
            <label for="photo">Charger une photo :</label>
            <input type="file" name="photo[1]" /><br />
            <input type="file" name="photo[2]" /><br />
            <input type="file" name="photo[3]" /><br />
 
 
            <input type="submit" class="submit" value="Charger" />
 
        </form>
 
 
 
 
 
        </div>
 
 
    </div>
</body>
</html>
d'avance merci