PHP Send file in HTML form to mail -


i want send 2 files attached email using html form. mail send 2 files can't see files when download (size: 0 ko). cant me please? here code of php file:

$boundary = "-----=".md5(uniqid(rand()));  $header  = "mime-version: 1.0\r\n"; $header .= "content-type: multipart/mixed; boundary=\"$boundary\"\r\n"; $header .= "\r\n";  $msg = "je vous informe que ceci est un message au format mime 1.0 multipart/mixed.\r\n";  $msg .= "--$boundary\r\n"; $msg .= "content-type: text/plain; charset=\"iso-8859-1\"\r\n"; $msg .= "content-transfer-encoding:8bit\r\n"; $msg .= "\r\n"; $msg .= "ceci est un mail avec 2 fichiers joints\r\n"; $msg .= "\r\n";  $file = $_files['icone']['name']; $fp   = fopen($file, "rb");   // le b c'est pour les windowsiens $attachment = fread($fp, filesize($file)); fclose($fp); $attachment = chunk_split(base64_encode($attachment));  $msg .= "--$boundary\r\n"; $msg .= "content-type: multipart/mixed; name=\"$file\"\r\n"; $msg .= "content-transfer-encoding: base64\r\n"; $msg .= "content-disposition: attachment; filename=\"$file\"\r\n"; $msg .= "\r\n"; $msg .= $attachment . "\r\n"; $msg .= "\r\n\r\n";  $file = $_files['nom_fichier']['name']; $fp = fopen($file, "rb"); $attachment = fread($fp, filesize($file)); fclose($fp); $attachment = chunk_split(base64_encode($attachment));  $msg .= "--$boundary\r\n"; $msg .= "content-type: multipart/mixed; name=\"$file\"\r\n"; $msg .= "content-transfer-encoding: base64\r\n"; $msg .= "content-disposition: attachment; filename=\"$file\"\r\n"; $msg .= "\r\n"; $msg .= $attachment . "\r\n"; $msg .= "\r\n\r\n";  $msg .= "--$boundary--\r\n";  $destinataire = "jeanb@hotmail.com"; $expediteur   = $_post['email']; $reponse      = $expediteur; echo "ce script envoie un mail avec 2 fichiers joints à $destinataire"; mail($destinataire,      "email avec 2 fichiers joints (dont 1 inline)",      $msg,      "reply-to: $reponse\r\nfrom: $destinataire\r\n".$header); 

the warning message is:

warning: fopen(date horloge.txt) [function.fopen]: failed open stream: no such file or directory in /home/public_html/mail_candidat.php on line 34

warning: filesize() [function.filesize]: stat failed date horloge.txt in /home/public_html/mail_candidat.php on line 35

warning: fread(): supplied argument not valid stream resource in /home/public_html/mail_candidat.php on line 35

warning: fclose(): supplied argument not valid stream resource in /home/public_html/mail_candidat.php on line 36

ce script envoie un mail avec 2 fichiers joints à jeanb@hotmail.com

the path file stored in 'tmp_name' , not in name. name how file called not path file.

in example be.

before

$file = $_files['nom_fichier']['name']; $fp = fopen($file, "rb"); $attachment = fread($fp, filesize($file)); fclose($fp); 

after

$file = $_files['nom_fichier']['tmp_name']; $fp = fopen($file, "rb"); $attachment = fread($fp, filesize($file)); fclose($fp); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -