note 57354 added to function.base64-encode
| From: | ds_available at yahoo dot com | Date: | Sat, 01 Oct 2005 08:30:14 +0000 |
| Subject: | note 57354 added to function.base64-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96119@lists.php.net to get a copy of this message | ||
to send multiple attatchments in your html mail
try this code
Dinesh Sharma
<?
$message = '
This is a multi-part message in MIME format.
------=_NextPart_001_0011_1234ABCD.4321FDAC
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hello
We have attached for you the file you requested
<html><body><font color=red>hi
dinesh<br></font></body></html>
Regards
Dinesh
' ;
foreach($_FILES['attachment']['error'] as $key => $error) {
if($error == UPLOAD_ERR_OK) {
$filename = $_FILES['attachment']['name'][$key];
$thisfile=$filename;
$filetype = $_FILES['attachment']['type'][$key];
// Encode the file ready to send it off
$handle = fopen($_FILES['attachment']['tmp_name'][$key],'rb');
$file_content =
fread($handle,filesize($_FILES['attachment']['tmp_name'][$key]));
fclose($handle);
$encoded = chunk_split(base64_encode($file_content));
// create the email and send it off
$message .= '------=_NextPart_001_0011_1234ABCD.4321FDAC
Content-Type: application/octet-stream;name="';
$message .= "$thisfile";
$message .= '"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="';
$message .= "$thisfile";
$message .= '"
';
$message .= $sep." $encoded".$sep;
}
}
$message .= '
------=_NextPart_001_0011_1234ABCD.4321FDAC--
';
echo $message."<br><br>";
?>
----
Manual Page -- http://www.php.net/manual/en/function.base64-encode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57354
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57354&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57354&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57354&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57354&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57354&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57354&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57354&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57354&report=yes
Search -- http://master.php.net/manage/user-notes.php