bonjour, j'ai crée une formulaire qui fais l'insertion des information dans la BD mais il y a un champs qui pas ajouter si un champ qui j'ai fait l'upload d'une photo le code de la formulaire est
touts les champs insérer sauf le champ 'photo' , je sais qu'il y a une erreur dans la recupiration de chemin puisque le code de la recupiration est
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 <form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="465" align="center"> <tr valign="baseline"> <td width="136" height="34" align="right" nowrap="nowrap"><strong>Code enseignant:</strong></td> <td width="317"><input type="text" name="code" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Code groupe<br /> de recherche:</strong></td> <td><input type="text" name="code_gr" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Nom:</strong></td> <td><input type="text" name="nom" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Prenom:</strong></td> <td><input type="text" name="prenom" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Grade:</strong></td> <td><input type="text" name="grade" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Tele:</strong></td> <td><input type="text" name="tele" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Fax:</strong></td> <td><input type="text" name="fax" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Adresse:</strong></td> <td><input type="text" name="adresse" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Email:</strong></td> <td><input type="text" name="email" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Photo:</strong></td> <td><label> <input type="file" name="photo" id="photo" /> <? // Taille max des fichiers (octets) $MFS=10000000024; // Répertoire de stockage $rep="upload/"; if(isset($_FILES['userfile'])) { if($_FILES['userfile']['size']>0) { $savefile= $rep.$_FILES['userfile']['name']; $temp = $_FILES['userfile']['tmp_name']; if (move_uploaded_file($temp, $savefile)) { ?> <b>Votre fichier a bien été enregistré !</b> <BR>Nom : <?echo $_FILES['userfile']['name'];?> <BR>Taille : <?echo $_FILES['userfile']['size'];?> o <BR>Type : <?echo $_FILES['userfile']['type'];?> <? } else { ?> <b>Erreur d'enregistrement !</b> <? } } else { ?> <b>Trop gros fichier !</b> <i>( <? echo $MFS;?> octets max.)</i> <? } } ?> </label></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"><strong>Service/membre:</strong></td> <td><input type="text" name="service_membre" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right" valign="top"><strong>Diplome:</strong></td> <td><textarea name="diplome" cols="50" rows="5"></textarea> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right" valign="top"><p><strong>Enseignament et</strong><strong><br /> cours récents:</strong></p> </td> <td><textarea name="Enseignament_cours" cols="50" rows="5"></textarea> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Insérer" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form>
et la requete d'insertion
Code : Sélectionner tout - Visualiser dans une fenêtre à part GetSQLValueString($_POST['photo'], "text"),comment pui-je recupirer le chemin de la photo
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 if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO enseignant (code, code_gr, nom, prenom, grade, tele, fax, adresse, email, photo, service_membre, diplome, Enseignament_cours) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['code'], "text"), GetSQLValueString($_POST['code_gr'], "int"), GetSQLValueString($_POST['nom'], "text"), GetSQLValueString($_POST['prenom'], "text"), GetSQLValueString($_POST['grade'], "text"), GetSQLValueString($_POST['tele'], "int"), GetSQLValueString($_POST['fax'], "int"), GetSQLValueString($_POST['adresse'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['photo'], "text"), GetSQLValueString($_POST['service_membre'], "text"), GetSQLValueString($_POST['diplome'], "text"), GetSQLValueString($_POST['Enseignament_cours'], "text"));
Partager