Then you should be able to use that function...

So are you storing the "Path" of the file in MYSQL or any other database?!?!!?

If not then replace

/-----

$file2 = ("./images/$data->name");

//------


to reflect your path...



Dan



On Wednesday, May 28, 2003, at 02:34 PM, [EMAIL PROTECTED] wrote:

I am storing the file on my server.


-----Original Message----- From: Dan Brunner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 2:42 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Email an attached file


Hello!!


  If your storing the file name, file type, in mysql; and are storing
the files on a server.
  (Which you should be doing!!!)



You could use this!!

//------------------------------------

        $query = "SELECT * FROM Images WHERE Num = $num";
        $result = mysql_query ($query, $db);    
        $data = mysql_fetch_object($result);


function sendfile($to, $subject, $text, $cc, $from, $file, $type) { $content = fread(fopen($file,"r"),filesize($file)); $content = chunk_split(base64_encode($content)); $uid = strtoupper(md5(uniqid(time()))); $name = basename($file); $text = stripslashes($text); $subject = stripslashes($subject);

        $header = "From: $from\nReply-To: $from\n";
        $header .= "Cc: $cc\n";
        $header .= "MIME-Version: 1.0\n";
        $header .= "Content-Type: multipart/mixed; boundary=$uid\n";

        $header .= "--$uid\n";
        $header .= "Content-Type: text/plain\n";
        $header .= "Content-Transfer-Encoding: 8bnoit\n\n";
        $header .= "$text\n";
        $header .= "\n";
        $header .= "\n";


$header .= "--$uid\n"; $header .= "Content-Type: $type; name=\"$name\"\n";

        $header .= "Content-Transfer-Encoding: base64\n";
        $header .= "Content-Disposition: attachment; filename=\"$name\"\n\n";
        $header .= "$content\n";

$header .= "--$uid--";

mail($to, $subject, "", $header);

}


$file2 = ("./images/$data->name"); $type = ("$data->filetype");

        $mess .= ("\n");
        $mess .= ("\n");
        $mess .= ("\n");
        $mess .= ("\n");
        $mess .= ("Here is that Pic you wanted...");

sendfile($To, $sub, $mess, $cc, $From, $file2, $type);



//-----------------


Of course all of the $To,$sub,etc...etc...etc...are from posting the data from a form.



I think you can figure out the rest....



Good luck!!




Dan Brunner




On Wednesday, May 28, 2003, at 01:12  PM, [EMAIL PROTECTED]
wrote:


www.phpclasses.org is your best bet. there are plenty. personally i use this one..http://phpclasses.com/browse.html/package/32.html

check out his site for examples.

hth
jd





                    "Marie Osypian"
                    <[EMAIL PROTECTED]       To:
<[EMAIL PROTECTED]>
                    llege.com>                  cc:
                                                Subject:     [PHP-DB]
Email an attached file
                    05/28/2003 02:08 PM






I am using something like this example code below to send e-mail and wondered if anyone could tell me how I could include a file also in this email if possible.

Thanks in advance.
Marie


EXAMPLE:


$myname = "Me Myself";
$myemail = "[EMAIL PROTECTED]";

$contactname = "Mister Contact";
$contactemail = "[EMAIL PROTECTED]";

$message = "hello from happy me";
$subject = "Included your file";

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$myname." <".$myemail.">\r\n";
$headers .= "To: ".$contactname." <".$contactemail.">\r\n";
$headers .= "Reply-To: ".$myname." <$myreplyemail>\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";
mail($contactemail, $subject, $message, $headers);



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to