Bonjour à tous
Voici ma difficulté:
j'ai un formulaire qui me permet d'uploader un fichier excel et des images. Ce formulaire consiste à ajouter des images dans ma base de donnée.

mon formulaire :
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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Mise à jour des membre</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
<body>
   <fieldset>
   		<legend>Importer le fichier des membre</legend>
        <caption>Veuillez sélectionnez le fichier</caption>
    <form enctype="multipart/form-data" action="listetransfere.php" method="POST">
       <label>Sélectionnez le fichier csv</label> <input name="filescsv" type="file" accept="application/msexcel"/><br>
       <label>Sélectionnez les photos</label> <input name="filesToUpload[]" id="filesToUpload" type="file" multiple='multiple' /><br>
        <input type="submit" value="Importer" name="importer" />
    </form> 
    </fieldset> 
</body>
</html>
traitement et affichage du contenu de mon fichier excel

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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php 
session_start();
	$tab = array();
	if(isset($_POST['importer']))
	{
	//récupération des photos
	$nbupload = count($_FILES['filesToUpload']['name']);
	  if ($nbupload != 0)
	  {
       for($i=0;$i<$nbupload;$i++)
       {
		 $tmp = $_FILES['filesToUpload']['tmp_name'][$i];
		 $ftmp = fopen($tmp, 'r');
		 $imgtmp = fread($ftmp,filesize($tmp));
         $tab[] = array('nom' => $_FILES['filesToUpload']['name'][$i], 
		                'value' => $_FILES['filesToUpload']['tmp_name'][$i],
		                'valblob' => $imgtmp);
       }
	  }
	  echo 'Le nombre de photo uploader est '.$nbupload;
	  //fin récupération des photos
	  $_SESSION['filetab']=$tab;
	  $_SESSION['nbtof']=$nbupload;
	 //echo'Le nombre de photo est: '.$nbupload.'<br>'; echo'La valeur de $tab est <br>';  var_dump($tab);  echo'<br>';
?>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
<body>
<div id='cases'>
<table width="900" border="1" align="center" cellpadding="2" cellspacing="0" bgcolor="#eeeeee">
<form name="form1" method="post" action="majupdate.php">
<tr>
  <th>MATRICULE </th>
  <th>NUMPOL</th>
  <th>POLREMP</th>
  <th>NUMCART</th>
  <th>NOM</th>
  <th>IDENREG</th>
  <th>PHOTO </th>
  <th>ACTION:<br/> <input type="checkbox" id="selectall"/> </th>
</tr>
<?php
//recupere le nom du fichier indiqué par l'user
$fichier=$_FILES['filescsv']['tmp_name']; // $fichier=$_FILES['filesToUpload']['tmp_name'][0];
$fichier1=$_FILES['filescsv']['name']; // $fichier=$_FILES['filesToUpload']['tmp_name'][0];
$extfile =pathinfo($_FILES['filescsv']['name'], PATHINFO_EXTENSION); ;
// ouverture du fichier en lecture
// declaration de la variable "cpt" qui permettra de compter le nombre d'enregistrement réalisé
$cpt=0;
if ($extfile == 'csv')
{
	if ($fichier)
	{
				//ouverture du fichier temporaire
				$fp = fopen($fichier,"r");
	}
	else{
	// fichier inconnu
		?>
		<p align="center">- Importation échouée -</p>
		<p align="center"><B>Désolé, mais vous n'avez pas spécifié de chemin valide ...</B></p>
		<?php
		exit();
	 }
	?>
		<p align="center">- Importation Réussie -</p>
 
<!-- <p align="right"><a href="#bas">Bas de page</a></p> -->
 
	<?php
    // importation
    while (!feof($fp))
    {
        $ligne = fgets($fp,4096);
        // on crée un tableau des élements séparés par des points virgule
        $liste = explode(";",$ligne);
        // premier élément
        $liste[0] = ( isset($liste[0]) ) ? $liste[0] : Null;
        $liste[1] = ( isset($liste[1]) ) ? $liste[1] : Null;
        $liste[2] = ( isset($liste[2]) ) ? $liste[2] : Null;
        $liste[3] = ( isset($liste[3]) ) ? $liste[3] : Null;
        $liste[4] = ( isset($liste[4]) ) ? $liste[4] : Null;
        $liste[5] = ( isset($liste[5]) ) ? $liste[5] : Null; 
 
		$champs0=$liste[5]; //matricule
        $champs1=$liste[0]; // numplo
        $champs2=$liste[1]; // polremp
        $champs3=$liste[2]; // numcart
        $champs4=$liste[3]; // nom
        $champs5=$liste[4]; // idenreg
		// suppression d'espace pour la concacténation
		$test1= trim("MEMBRE_PHOTOAD1_");
		$test2=trim(".JPG");
		$test3=trim($champs5);
		$testimg=$test1.$test3.$test2;// fin de concacténation
        //$testimg="MEMBRE_PHOTOAD1_".$champs5."."."JPG"; // photo //echo 'le nom du champ 5 avant fonction est :'.$testimg.'<br>';
		//$imgtest = str_replace (" ", "", $testimg);
        file_exists($testimg) ? $champs6='nothing'.'.JPG' : $champs6=$testimg;
		//echo 'le nom du champ 6 après fonction est :'.$champs6.'<br>';// pour eviter que le champs "nom" du fichier soit vide
        if ($champs1!='')
        {
        $cpt++; // nouvel ajout, compteur incrémenté
        ?>
	<tr>
      	<td width="80"><?php echo $champs0;?></td>
        <td width="80"><?php echo $champs1;?></td>
        <td width="80"><?php echo $champs2;?></td>
        <td width="90"><?php echo $champs3;?></td>
        <td width="310"><?php echo $champs4;?></td>
        <td width="80"><?php echo $champs5;?></td>
        <td width="60"><img src="../MEMBRE/<?php echo $champs6;?>" width="50" height="50" alt="Aucune image"/></td>
        <td align="center" bgcolor="#FFFFFF" width="180">
 <input type="checkbox" class="case" name="valbox[]" id="valbox[]" value='<?php echo $liste[1].';'.$liste[3].';'.$champs6.';'.$champs0.';'.$champs5;?>'/>
 
        </td>
	</tr>
 
	<?php
	}
  }
?>
<tr>
  <td colspan="7" align="center" bgcolor="#FFFFFF"><input name="update" type="submit" id="update" value="Ajouter les photos"></td>
</tr>
<?php
// fermeture du fichier
fclose($fp);
}
?>
</form>
</table>
</div> 
<br><br>Nombre de valeurs nouvellement importée: <b><?php echo $cpt;?></b>   
<?php
	}		
?>
<SCRIPT language="javascript">
$(function(){
 
    // add multiple select / deselect functionality
    $("#selectall").click(function () {
          $('.case').attr('checked', this.checked);
    });
    $(".case").click(function(){
        if($(".case").length == $(".case:checked").length) {
            $("#selectall").attr("checked", "checked");
        } else {
            $("#selectall").removeAttr("checked");
        }
    });
});
</SCRIPT>
</body>
</html>
majupdate.php
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
<?php
session_start();
//connexion bd
/******connexion à la bd**********/
$dbh = new PDO("mysql:host=localhost;dbname=sogemad", 'root', '');
/********set the error mode**********/
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//fin connexion
  $toftabp= array();
  $toftabp= $_SESSION['filetab'];// nouvel ajout, compteur incrémenté
  $nbtofp = $_SESSION['nbtof']; //nombre de photo
	if (isset($_POST['update']))
	{
		if (isset($_POST['valbox'])){
		 $site = $_POST['valbox'];
		$nbcheck= count($site);
		echo 'Vous avez cochez : '.$nbcheck.'<br>';
		foreach ($site as $choix)
		{
			$val = explode(";", $choix);
	//recherche dans le tableau pour la conversion de la photo en blob
					for($i=0;$i<$nbtofp;$i++)
					{
					   $valimg = $toftabp[$i]['nom'];
					 if($toftabp[$i]['nom']===$valimg)
					  {
 
							$vablobp = $toftabp[$i]['valblob'];
								 $imgfp = $vablobp;
								 $typephoto ='JPG';
								 $matric = $val[3];
			try{
	             /********our sql query ***********/
				$stmt = $dbh->prepare("UPDATE tmembre SET Typephotoad1 = :type_img, PHOTOAD1 = :imagephoto WHERE matmembre = :matri");
				/******bind the params *********/
				$stmt->bindParam('type_img', $typephoto);
				$stmt->bindParam('imagephoto', $imgfp, PDO::PARAM_LOB);
				$stmt->bindParam('matri', $matric);
				/***** execute the query ********/
				$stmt->execute(); 
			}
				catch (Exception $e) { die('Erreur : ' . $e->getMessage());}
				 //
					  }
					}
		}
	   }
	   else 
	    { echo'Veuillez cocher au moins une case pour effectuer une Mise à jour'; }
	}
?>
voici la structure de ma table
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE I `tmembre` (
  `NUMPOL` varchar(7) NOT NULL,
  `POLREMPL` varchar(20) NOT NULL,
  `NUMCART` varchar(10) DEFAULT NULL,
  `NOM` varchar(60) DEFAULT NULL,
  `IDENREG` int(11) NOT NULL,
  `PHOTOAD1` blob,
  `Typephotoad1` varchar(5) DEFAULT NULL,
  `matmembre` varchar(20) NOT NULL,
  PRIMARY KEY (`matmembre`)
)
lorsque j’exécute , la requête de modification, il y a aucune modification dans ma base et aussi aucun message d'erreur.
Merci pour tout aide et tout conseille.