在附件文件的joomla联系表单中添加字段

时间:2013-12-26 03:41:59

标签: joomla php

请帮助我我正在使用joomla v 3我正在尝试以联系方式添加字段我已将所有代码设置在joomla文件中但附加文件未接收?请参阅下面的代码。

$filename = $data['filename'];

$name = $data['contact_name'];
$subject = $data['contact_subject'];

$body = $data['contact_message'];



$mime_boundary = "==Multipart_Boundary_x" . md5(mt_rand()) . "x";

// Now Store the file information to a variables for easier access

$tmp_name = $_FILES['filename']['tmp_name'];

$type = $_FILES['filename']['type'];

$file_name = $_FILES['filename']['name'];

$size = $_FILES['filename']['size'];

//现在我们在这里设置邮件的消息

$message = "\n\n Here is your file: $file_name";

if (file_exists($tmp_name)) {


if (is_uploaded_file($tmp_name)) {


    $file = fopen($tmp_name, 'rb');


    $data = fread($file, filesize($tmp_name));


    fclose($file);


    $data = chunk_split(base64_encode($data));
}


$headers = "From: $body\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: multipart/mixed;\r\n" .
        " boundary=\"{$mime_boundary}\"";

$message = "This is a multi-part message in MIME format.\n\n" .
        "--{$mime_boundary}\n" .
        "Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
        "Content-Transfer-Encoding: 7bit\n\n" .
        $message . "\n\n";

//现在我们将插入一个边界来表示我们正在启动附件,我们必须将内容类型,文件名和处置指定为附件,然后添加文件内容并设置另一个边界以指示已达到文件末尾

$message .= "--{$mime_boundary}\n" .
        "Content-Type: {$type};\n" .
        " name=\"{$file_name}\"\n" .

//“Content-Disposition:attachment; \ n”。 //“filename = \”{$ fileatt_name} \“\ n”。

        "Content-Transfer-Encoding: base64\n\n" .
        $data . "\n\n" .
        "--{$mime_boundary}--\n";

}

//准备电子邮件正文

$body = $prefix . "\n" . $name . ' <' . $email . '>' . "\n" . $filename . "\r\n\r\n" . stripslashes($body);

$mail = JFactory::getMailer();
$mail->addRecipient($contact->email_to);
$mail->addReplyTo(array($email, $name));
$mail->setSender(array($mailfrom, $fromname));
$mail->setSubject($sitename . ': ' . $subject);
$mail->setBody($body, $headers);
$sent = $mail->Send();

文件名在我已设置的正文中接收但文件未在邮件中接收。

我已设置<input type="file" name="filename"/>

请为我检查

0 个答案:

没有答案