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 :
<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> </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 :
<?
// 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">
Configuration: Windows XP
Firefox 3.0.6