$attachment_name=$_FILES['userfile']['name'];
if($attachment_name!="")
{
$ee=explode(".",$attachment_name);
$cc=count($ee)-1;
$type1=strtolower($ee[$cc]);
if($type1!='doc' and $type1!='pdf' )
{
echo"Please make sure that the abstract file type is in .doc or .pdf format. Please go back and change it, thanks.";
exit;
}
}
$uploaddir='mail/';
$uploadfile=$uploaddir.$_FILES['userfile']['name'];
move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile);
$attachment_name=$_FILES['userfile']['name'];
$attachment_type=$_FILES['userfile']['type'];
$attachment=$uploadfile;
$from="$_POST[Email]";
$to="kyleung@hkbu.edu.hk;lshk.arf2008@gmail.com;manvicky4work@gmail.com;sw.tang@polyu.edu.hk";
$subject="ARF 2008 - Online Registration";
$body="
Last Name: $_POST[Last_name]
First Name: $_POST[First_name]
Title: $_POST[Title]
Chinese Name: $_POST[Chinese_name]
Affiliation: $_POST[Affiliation]
Other Affiliation: $_POST[Other_affiliation]
Address: $_POST[Address]
Telephone: $_POST[Telephone]
Fax No: $_POST[Fax]
Email: $_POST[Email]
LSHK membership status: $_POST[Membership_status]
Current Category: $_POST[Current_category]
Wanna Join: $_POST[Wanna_Join]
Do you intend to present in ARF?: $_POST[Present]
Paper Title: $_POST[Paper_title]
Author(s): $_POST[Author]
Affiliation(s): $_POST[Affiliation2]
Email(s): $_POST[Email2]
Special Equipment Request: $_POST[Equipment_request]
";
//echo $body."
";
//echo $body."
";
//定义分界线
$boundary=uniqid("");
//生成邮件头
$headers = "From: $from
Content-type: multipart/mixed; boundary=\"$boundary\"";
//确定上传文件的MIME类型,如果浏览器没有指定文件的MIME类型,我们可以把它定义为"application/unknown"
if($attachment_type) $mimeType=$attachment_type;
else $mimeType="application/unknown";
//确定文件名
$fileName=$attachment_name;
//打开文件
echo $attachment;
$fp=fopen($attachment,"r");
//把整个文件读入一个变量
$read=fread($fp,filesize($attachment));
//变量$read中保存的是包含整个文件内容的文本块,把这个文本块转换成邮件程序可以读懂的格式,用base64方法把它编码
$read=base64_encode($read);
//为一个用base64方法编码的长字符串,把该字符串切成由每行76个字符组成的小块
$read=chunk_split($read);
//建立邮件主体
$body = "--$boundary
Content-type: text/plain; charset=GB2312
Content-transfer-encoding: 8bit
$body
--$boundary
Content-type: $mimeType; name=$fileName
Content-disposition: attachment; filename=$fileName
Content-transfer-encoding: base64
$read
--$boundary--";
//echo $to."
";
//echo $subject."
";
//echo $body."
";
//echo $headers."
";
if(mail($to,$subject,$body,$headers)) echo "ok";
echo "";
?>