Bonjour à tous!!!
Voila j'ai un tableau qui se rempli au fur et à mesure et dans chaque ligne j'ai mis un input file. Le but de ma manoeuvre est que pour chaque ligne qui contient un lot, que l'on puisse ulpoader des fichiers pour le lot situé sur la même ligne et tout ça sans que l'on change de page. J'ai utilisé pour cela un formdata en javascript qui l'envoie en ajax dans une page php qui va mettre les fichiers en BDD. Mais le soucis c'est que j'ai rien dans ma BDD et je n'arrives pas à trouver l'erreur.
voici mon tableau:
Mon code javascript:
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 <table class="table" > <tr class="couleur5"> <th class="th" rowspan="3" style="min-width:100px;">N° lot</th> <th class="th" rowspan="3" style="min-width:100px;">Qte</th> <th class="th" rowspan="3" style="min-width:100px;">Fichier</th> <th class="th" rowspan="3" style="min-width:100px;">Date de reception</th> <th class="th" colspan="3" >Conformité</th> </tr> <tr > <th class="th" style="background-color:#E8BEBE;width:50px;">NOK</th> <th class="th" style="background-color:#EEEEBE;width:50px;">DRG</th> <th class="th" style="background-color:#BEE8BE;width:50px;">OK </th> </tr> <tr class="couleur5"> <th class="th" style="background-color:#E8BEBE;width:50px;"> <input id="piece_nok" name='piece_livre[]' style="margin-top:6px;margin-left:4px;height:15px;width:15px;" type="radio"/> </th> <th class="th" style="background-color:#EEEEBE;width:50px;"> <input id="piece_drg" name='piece_livre[]' style="margin-top:6px;margin-left:4px;height:15px;width:15px;" type="radio" /> </th> <th class="th" style="background-color:#BEE8BE;width:50px;"> <input id="piece_ok" name='piece_livre[]' style="margin-top:6px;margin-left:4px;height:15px;width:15px;" type="radio"/> </th> </tr> <tr> <?php $flag_couleur1 = 0; while($result1 = @oci_fetch_assoc(@$statement1)) { ?> <td class="td"><?php echo $result1['NUM_LOT_DEG']; ?></td> <td class="td"><?php echo $result1['QUANTITE']; ?></td> <td><input name="controle_qualite[]" type="file" id='champFile' multiple="multiple" onClick="AffID_QUA(<?php echo $result1['ID_VALIDATION_QUALITE'];?>);" style="float:left;width:100%;"></td> <td class="td"><?php echo $result1['DATE_RECEPTION']; ?></td> <td class="td" style="background-color:#E8BEBE;"> <input id="piece_nok" name='piece_livre[]' onclick="val_qualite(<?php echo $result1['ID_VALIDATION_QUALITE'];?>,1);" style="margin-top:6px;margin-left:4px;height:15px;width:15px;" type="radio"/> </td> <td class="td" style="background-color:#EEEEBE;"> <input id="piece_drg" name='piece_livre[]' onclick="val_qualite(<?php echo $result1['ID_VALIDATION_QUALITE'];?>,2);" style="margin-top:6px;margin-left:4px;height:15px;width:15px;" type="radio" /> </td> <td class="td" style="background-color:#BEE8BE;"> <input id="piece_ok" name='piece_livre[]' onclick="val_qualite(<?php echo $result1['ID_VALIDATION_QUALITE'];?>,3);" style="margin-top:6px;margin-left:4px;height:15px;width:15px;" type="radio"/> </td> <tr> <?php $flag_couleur1++; } ?> </tr> </table>
Et enfin script php d'envoi dans ma BDD:
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 var id; function AffID_QUA(id_val_qua) { id=id_val_qua; } $(function() { $('#champFile').change(function() { var formdata = new FormData(); var fichier = document.getElementById('#champFile').files[0]; formdata.append("fichier", fichier); formdata.append("id_val_qua", id); var ajax = new XMLHttpRequest(); ajax.open("POST", "maj_fichier_qualite.php"); ajax.send(formdata); }); });
Voila si quelqu'un pouvais m'aider ça serai super car la je bloque .
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 foreach($_FILES['fichier']['tmp_name'] as $i => $fichier_nom) { if(!empty($fichier_nom)){ $type = $_FILES['fichier']['type'][$i]; $name = $_FILES['fichier']['name'][$i]; $lob = oci_new_descriptor($conn, OCI_D_LOB); $stmt = oci_parse($conn, "insert into POP_FICHIER_QUALITE_EN_COURS (ID_VALIDATION_QUALITE,TYPE_FIHCIER_QUALITE_EN_COURS,LABEL_FICHIER_QUALITE_EN_COURS,FICHIER_QUALITE_EN_COURS) values(".$_POST['id_val_qua'].",'".$type."','".$name."', EMPTY_BLOB()) returning FICHIER_QUALITE_EN_COURS into :FICHIER_QUALITE_EN_COURS"); oci_bind_by_name($stmt, ':FICHIER_QUALITE_EN_COURS', $lob, -1, OCI_B_BLOB); oci_execute($stmt, OCI_DEFAULT); if($lob->savefile($fichier_nom)){ oci_commit($conn); } $lob->free(); oci_free_statement($stmt); } }
Partager