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
|
<?php
//-----------------------------------------------
//PIECE JOINTE
//-----------------------------------------------
$uploaddir = '../uploads/';
$upload_file = $uploaddir . $_FILES['Fichier']['name'];
if (move_uploaded_file($_FILES['Fichier']['tmp_name'], $upload_file)) {
$ext = explode(".", basename($_FILES['Fichier']['name']));
switch($ext[1]) {
default:
$attach_type = "application/octet-stream";
break;
case "gz":
$attach_type = "application/x-gzip";
break;
case "tgz":
$attach_type = "application/x-gzip";
break;
case "zip":
$attach_type = "application/zip";
break;
case "pdf":
$attach_type = "application/pdf";
break;
case "png":
$attach_type = "image/png";
break;
case "gif":
$attach_type = "image/gif";
break;
case "jpg":
case"jpeg":
$attach_type = "image/jpeg";
break;
case "txt":
$attach_type = "text/plain";
break;
case "htm":
$attach_type = "text/html";
break;
case "html":
$attach_type = "text/html";
break;
}
$attach_name = $_FILES["Fichier"]["name"];
}
if (file_exists($upload_file)) {
$file = fopen($upload_file, "r");
$contents = fread($file, filesize($upload_file));
$encoded_attach = chunk_split(base64_encode($contents));
fclose($file);
}
//-----------------------------------------------
//HEADERS DU MAIL
//-----------------------------------------------
$headers = 'From : <'.$EmailExpediteur.'>'."\n";
$headers .= 'Return-Path: <inscription@massageavenue.fr>'."\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-Type: multipart/mixed; boundary="'.$frontiere.'"';
$headers .= "Content-transfer-encoding: 7BIT\n";
$headers .= "X-attachments: $attach_name\n";
$message .= $frontiere."\r\n";
$message .= "Content-type: $attach_type; name=\"$attach_name\n";
$message .= "Content-Length: " . filesize($upload_file) . "\n";
$message .= "Content-transfer-Encoding: BASE64\n";
$message .= "Content-Disposition: attachment; filename=\"$attach_name\"\n\n";
$message .= "$encoded_attach\n";
$message .= $frontiere."\r\n";
if(mail($email_destinataire,$sujet,$message,$headers))
{
echo 'Le mail a été envoyé';
?>
<input type="submit" name="Validation" id="Validation" value="Retour à la page d'accueil" onclick="self.location.href =' ../index.php'"/>
<?php
}
else
{
echo 'Le mail n\'a pu être envoyé';
?>
<input type="submit" name="Validation" id="Validation" value="Retour au formulaire" onclick="self.location.href =' ../php/FormulaireInscription.php'"/>
<?php
}
?> |
Partager