Bonjour,
J'ai récement trouver un formulaire avec envoi de pièce jointe qui fonctionne, je voudrais maintenant le perfectionner en proposant l'envoi de 5 pièce jointe sauf que .... je sais pas ce qu'il faut rajouter en php , je connais le php mais pas du tout les expressions pour ce qui est traitement d'un fichier.

Voila ma page index.htm qui contient le formulaire html :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
<form name="contact" method="post" action="contactok.php" enctype="multipart/form-data">
Nom :<input type="text" name="nom" size="20"></p>
  <p>Email<input type="text" name="mail" size="20"></p>
  <p>Message<input type="text" name="message" size="20"></p>
 
<input type=file size=40 name="attach">
<input type=file size=40 name="attach2">
 
  <p>&nbsp;</p>
  <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

ET maintenant la page php qui traite les informations :

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
<?
 
	// ADRESSE DU DESTINATAIRE
	$to="xxxxxx@gmail.com";
 
//
 
	// SUJET DU MESSAGE
	$sujet=".Message.";
 
	// ENTETES
	$entetes="From:$nom $prenom<info@coco-photocop.fr>\r\n";
 
	// MESSAGE
	$msg.="\nNom : $nom\n";
	$msg.="E mail : $mail\n";
	$msg.="\nMessage :\n\n$message";
 
	$msg = stripslashes($msg); 
 
 
 
	if (is_uploaded_file($attach)) {
    $file = fopen($attach, "r");
    $contents = fread($file, $attach_size);
    $encoded_attach = chunk_split(base64_encode($contents));
    fclose($file);
 
   $entetes.= "MIME-version: 1.0\n";
   $entetes.= "Content-type: multipart/mixed; ";
   $entetes.= "boundary=\"Message-Boundary\"\n";
   $entetes.= "Content-transfer-encoding: 7BIT\n";
 
    $body_top = "--Message-Boundary\n";
    $body_top .= "Content-type: text/plain; charset=US-ASCII\n";
    $body_top .= "Content-transfer-encoding: 7BIT\n";
    $body_top .= "Content-description: Mail message body\n\n";
 
    $msg .= "\n\n--Message-Boundary\n";
    $msg .= "Content-type: $attach_type; name=\"$attach_name\"\n";
    $msg .= "Content-Transfer-Encoding: BASE64\n";
    $msg .= "Content-disposition: attachment; filename=\"$attach_name\"\n\n";
    $msg .= "$encoded_attach\n";
    $msg .= "--Message-Boundary--\n";
  }
 
$msg = $body_top.stripslashes($msg);	
 
	if (mail($to,$sujet,$msg,$entetes))
	{ ...


Voila je sais pas comment traiter le 2eme fichier <input type=file size=40 name="attach2">

Merci d'avance pour vos réponses