Bonjour
Posté le: 07 Avr 2008, 14:47 Sujet du message: UPLOAD fde fichier sur un serveur HTTP en PHP
--------------------------------------------------------------------------------
Bonjour
mon problème est que je veux uploader des pièce joite dans mes posts (etant donées que c'est un module tickets sous forme de forum à chaque ticket on veut uploader une pièce jointes)
voici mon code de Creer ticket.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
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 <form name="formulaire" action="confirmation_tcreate.php" method="post" enctype="multipart/form-data" onSubmit="return(verifForm(formulaire));"> <script language="JavaScript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--></script> <br> <table class="border" align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td><table border="0" cellpadding="5" cellspacing="1" width="100%"> <tbody> <tr > <td colspan="2" bgcolor="#f1f3f5" height="48" align="left" ><b>Expéditeur</b></td> </tr> <tr> <td bgcolor="#f1f3f5" width="204" height="48" align="right" >Centre d'appel :</td> <td class="back" width="585"><?php $con=mysql_connect("localhost","root","") or die("erreur de connexion");//connexion à la base de donnée mysql_select_db("mypraxys")or die("erreur de selection"); $sql="SELECT call_center_name FROM profil_call_center WHERE profil_id=$call_center"; $exec=mysql_query($sql); while($data=mysql_fetch_array($exec)) $center=$data[0]; echo $center; ?></td> </tr> </tbody> </table></td> </tr> </tbody> </table> <br> <table class="border" align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td><table border="0" cellpadding="5" cellspacing="1" width="100%"> <tbody> </tbody> </table></td> </tr> </tbody> </table> <br> <table class="border" align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td><table border="0" cellpadding="5" cellspacing="1" width="100%"> <tbody> <tr > <td colspan="2" bgcolor="#f1f3f5" height="48" align="left" ><b>Details ticket</b></td> </tr> <tr> <td bgcolor="#f1f3f5" align="right" width="27%">Intitulé du ticket :</td> <td width="120" colspan="3" class="back"> <input size="60" name="nom_ticket" value="" type="text" id="nom_ticket" maxlength="20" onsubmit="return(verifForm(formulaire)"> </td> </tr> <tr> <td bgcolor="#f1f3f5" align="right" width="27%">Type du ticket :</td> <td width="120" colspan="3" class="back"> <select name ="type_ticket" size=1> <option value ="1" > proposition </option> <option value ="2" > problème </option> <option value ="3" > aide </option> </select> </td> </tr> <tr> <td bgcolor="#f1f3f5" align="right" valign="top" width="27%">Description: </td> <td class="back" colspan="3"> <textarea name="description_ticket" rows="5" cols="60" id="description_ticket" onsubmit="return(verifForm(formulaire));"></textarea></td> </tr> <tr> <td bgcolor="#f1f3f5" align="right" valign="top" width="27%">Fichier attaché: </td> <td class="back" colspan="3" valign="bottom"> <input name="MAX_FILE_SIZE" value="1000000" type="hidden"> <input type="file" name="fichier" size="35"> <input type="hidden" name="upload" value="Uploader"> </td> </tr> </tbody> </table></td> </tr> </tbody> </table> <br> <center> <input name="create" value="Valider" type="submit"> <input name="reset" value="Rénitialiser" type="reset"> <input name="sg" value="2" type="hidden"> </center> </form>
pour le fichier confirmation_tcreate.php voici le code
/////////////////////////////////////////////////////////////////
_________________________________________________________________
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 if(isset($_POST['upload']))//si formulaire soumis { $content_dir='upload/';//dossier où sera déplacer le fichier $tmp_file=$_FILES['fichier']['tmp_name']; if(!is_uploaded_file($tmp_file)) { exit("Le fichier est introuvable"); } //on vérifie maintenant l'extention du file $type_file=$_FILES['fichier']['type']; if(!strstr($type_file,'jpg')&& !strstr($type_file,'jpeg')&& !strstr($type_file,'bmp')&& !strstr($type_file,'gif')) { exit("Le fichier n'est pas une image"); } //on copie le fichier dans le dossier de destination $name_file=$_FILES['fichier']['name']; if (!move_uploaded_file($tmp_file,$content_dir.$name_file)) { exit("Impossible de copier le fichier dans le dossier de destination"); } echo"Le fichier a bien été uploadé"; } ?> <?php $con=mysql_connect("localhost","root","") or die("erreur de connexion");//connexion à la base de donnée mysql_select_db("mypraxys")or die("erreur de selection");// selection de la base de donée //include('connection.php'); $dt=date("Y-m-d H:i"); $user_num=$_SESSION['id_user']; $ticket_name=$_POST['nom_ticket']; $ticket_type=$_POST['type_ticket']; $Description=$_POST['description_ticket']; $sql="Insert into ticket (ticket_name,ticket_type_id,content,ticket_status,user_id,date_post) values ('$ticket_name','$ticket_type','$Description','Open',$user_num,'$dt')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?>
et ca me donne toujours une erreur au niveau de if !(move_uploaded_file($tmp_file,$content_dir,$name_file))
Warning: Wrong parameter count for move_uploaded_file() in c:\program files\easyphp1-8\www\fatmamode05-04\confirmation_tcreate.php on line 81
Impossible de copier le fichier dans le dossier de destination
Pourriez vous me dire qu'est ce qui ne va pas avec mon code ??
Partager