$handle=fopen($attachments[$i]["file"], 'rb'); $f_contents=fread($handle, filesize($attachments[$i]["file"])); $f_contents=chunk_split(base64_encode($f_contents)); //Encode The Data For Transition using base64_encode(); fclose($handle);
$msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol; $msg .= "Content-Transfer-Encoding: base64".$eol; $msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $f_contents.$eol.$eol;
} }
# Setup for text OR html $msg .= "Content-Type: multipart/alternative".$eol;
ini_set(send_mail,$fromemail); // the INI lines are to force the From Address to be used ! mail($toemail, $subject, $msg, $headers); ini_restore(send_mail); echo "mail sent successfully"; } }
To: ($toemail) Subject: ($subject) File Attachment ($attach) Message ($message)
what's wrong with my script?Mr. Olaf? When i received...it shows nothing in attachment with 0kb capacity besides that...my message content also cannot received.Anything wrong of this scripts?
Thanks!!
« Last Edit: Mar 19, 2007, 05:43:11 PM by Taka »
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8037
41179 credits Members referred : 3
« Reply #1 on: Mar 19, 2007, 05:41:30 PM »
The attachment is a file that should be in your server.
$path is the path to that file, while $filename is the name of that file.
If you want to attach a file that the user uploads use the $_FILES array
How i going to retrieve the path that user upload?and pass to where?Furthermore, is it any errors part in my script? can you give some example by using my script?tq~!
« Last Edit: Mar 19, 2007, 06:26:24 PM by Taka »
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 8037
41179 credits Members referred : 3
« Reply #5 on: Mar 19, 2007, 06:39:33 PM »
I am sorry I am a busy man too
You may want to check those regarding file uploads :