PDA

View Full Version : attachment through a web form



evandaeman
25 Jul 2006, 01:53 PM
I have read several tutorials on mime in php

i can set up a php form mail very easily... and send information to e-mail and database.

however i still can't figure out how to attach a picture or a file through a web form to send to a e-mail.

has anyone created tutorials on this?? i found a few but were not clear


can anyone help me with this???

can you post your code on how to add a simple attachment and send it to an email?


thanks :angel:

Rincewind
30 Jul 2006, 04:12 AM
You would do it in two parts. First upload the file to the server, check it's safe and virus free etc. Next build your email and inlude the attached file in one of the email headers e.g. To do a MS word file you might have something like:

$message .= "Content-Type: application/msword; name=\"my attachment\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment; filename=\"$attachement\"\n\n";

Where $attachement is the variable containing the file you uploaded in the first part.

More info can be found by RTFM at php.net. Look under mail and mail().
http://cn.php.net/manual/en/ref.mail.php
http://cn.php.net/manual/en/function.mail.php