我有这个完美运行的脚本,但附件是空的(我的意思是我可以看到附件..但我加载的每个文件的大小都是 0 kb)这里是代码:
allegato 意味着附件
$path = $allegato['tmp_name'];
$fp = fopen($path, 'r');
do //we loop until there is no data left
{
$data = fread($fp, 8192);
if (strlen($data) == 0) break;
$content .= $data;
} while (true);
$content_encode = chunk_split(base64_encode($content));
$mime_boundary = "<<<--==+X[".md5(time())."]";
$headers .= "From:".$email."\r\n";
$headers .= "To: me <mail@gmail.com>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed;\r\n";
$headers .= " boundary=\"".$mime_boundary."\"";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n";
$message .= "\r\n";
$message .= "Email sent from:".$nome." \r\n";
$message .= $messaggio."\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: ".$allegato_type."\"\r\n";
$message .= " name=\ ".$allegato_name."\"\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition: attachment;\r\n";
$message .= " filename=\ ".$allegato_name."\"\r\n";
$message .= "\r\n";
$message .= $content_encode;
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$ok = mail("mail@gmail.com", $object, $message, $headers);
if($ok)
{
echo'<script type="text/javascript">alert("mail sent successfully ! ");</script>';
}
else
{ echo'<script type="text/javascript">alert("mail failed! ");</script>';}
有人可以帮忙处理附件吗?(发送的每个文件都是 0 kb,我如何修复它?)