Bonjour, j'ai un code php trouvé sur internet que je souhaiterai améliorer.
Pour comprendre, je cherche à faire un formulaire avec envoi de plusieurs pièces jointe.
LE code marche pour l'envoi d'un fichier, (si c'est une image elle est incorporé dans le coprs du message)
Je souhaite ajouter la possibilité d'envoyer une 2eme pièce jointe.
Il doit y avoir une erreur de syntaxe car la 1ere pièce jointe est inclus dans le mail que je recoi mais la seconde c'est comme si elle existait pas ....
if (is_uploaded_file($attach)) {
$file = fopen($attach, "r");
$contents = fread($file, $attach_size);
$encoded_attach = chunk_split(base64_encode($contents));
fclose($file);
$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";
}
if (is_uploaded_file($attach2)) {
$file2 = fopen($attach2, "r");
$contents2 = fread($file2, $attach2_size);
$encoded_attach2 = chunk_split(base64_encode($contents2));
fclose($file2);
$msg .= "\n\n--Message-Boundary\n"; //
$msg .= "Content-type: $attach2_type; name=\"$attach2_name\"\n";
$msg .= "Content-Transfer-Encoding: BASE64\n";
$msg .= "Content-disposition: attachment; filename=\"$attach2_name\"\n\n";
$msg .= "$encoded_attach2\n";
$msg .= "--Message-Boundary--\n";
}
JE pense que je avez compris que les 2 input file sont nommées :
- attach
- attach2
Merci d'avance !
Bonjour, j'ai un code php trouvé sur internet que je souhaiterai améliorer.
Pour comprendre, je cherche à faire un formulaire avec envoi de plusieurs pièces jointe.
LE code marche pour l'envoi d'un fichier, (si c'est une image elle est incorporé dans le coprs du message)
Je souhaite ajouter la possibilité d'envoyer une 2eme pièce jointe.
Il doit y avoir une erreur de syntaxe car la 1ere pièce jointe est inclus dans le mail que je recoi mais la seconde c'est comme si elle existait pas ....
[php]
if (is_uploaded_file($attach)) {
$file = fopen($attach, "r");
$contents = fread($file, $attach_size);
$encoded_attach = chunk_split(base64_encode($contents));
fclose($file);
$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";
}
if (is_uploaded_file($attach2)) {
$file2 = fopen($attach2, "r");
$contents2 = fread($file2, $attach2_size);
$encoded_attach2 = chunk_split(base64_encode($contents2));
fclose($file2);
$msg .= "\n\n--Message-Boundary\n"; //
$msg .= "Content-type: $attach2_type; name=\"$attach2_name\"\n";
$msg .= "Content-Transfer-Encoding: BASE64\n";
$msg .= "Content-disposition: attachment; filename=\"$attach2_name\"\n\n";
$msg .= "$encoded_attach2\n";
$msg .= "--Message-Boundary--\n";
}
[/php] JE pense que je avez compris que les 2 input file sont nommées :
- attach
- attach2
Merci d'avance !