0
亲爱的朋友们, 我有文件附件的问题,我正在使用电子邮件功能附件为我的项目,我附带file.xls与该邮件,但在邮件我不能得到该文件的值,其显示0K。 但在本地该文件是有一些DATAS,但它不工作时运行的电子邮件功能,附件有0K大小,任何人都可以帮我请... 我的代码如下....发送带附件的电子邮件(问题是文件大小为0k)
$filename = "test.xls";
$path = $_SERVER['DOCUMENT_ROOT']."/path/to/Documents/";
$file = $path.$filename;
$to = "[email protected]";
$subject = 'Repairs List Report';
$message = "Please find the attachment file for repairs list of Last week..."; //strip_tags($_POST['message']);
$attachment = chunk_split(base64_encode(file_get_contents($file)));
//$filename = $_FILES['file']['name'];
$boundary =md5(date('r', time()));
$headers = "From: [email protected]\r\nReply-To: [email protected]";
$headers .= "MIME-Version: 1.0";
$message="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/vnd.ms-excel; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--";
mail($to, $subject, $message, $headers);
你能告诉我们你使用的代码吗?另外,你的意思是“收到时的附件是0 kb”?这并不完全清楚。 – Piskvor 2011-01-25 13:39:31