Upload attachment and email HELP!!!


I was wondering if anyone could help me. I am have made a very simple html form that uses php to email the data collected. What I am trying to do is have an upload attachment in the form, and have this also sent in the email. I have tried a few things, but nothing seems to work. This is waht I have so far:

In my html form:


Please fill out the form and we will endeavour to get back to you as soon as possible.

      <span class="style7">.</span></p>          </td>
    <td colspan="2"><table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
     <?php include("send_contact_MAW_001.php"); ?>   

switch ($action) {
case “send”:


and in my php handeller:



Phone :
Industry :
Attachment :
Enquiry :


function sendMail() {
if (!isset ($_POST[‘from_email’])) { //Oops, forgot your email addy!
die (“

Oops! You forgot to fill out the email address! Click on the back arrow to go back

else {
$Name = stripslashes($_POST[‘Name’]);
$Subject = stripslashes($_POST[‘Subject’]);
$Phone = stripslashes($_POST[‘Phone’]);
$Industry = stripslashes($_POST[‘Industry’]);
$Enquiry = stripslashes($_POST[‘Enquiry’]);
$Email = $_POST[‘Email’];
$Attachment = $_FILES[‘Attachment’][‘tmp_name’];
$attachment_name = $_FILES[‘attachment’][‘name’];
if (is_uploaded_file($attachment)) { //Do we have a file uploaded?
$fp = fopen($attachment, “rb”); //Open it
$data = fread($fp, filesize($attachment)); //Read it
$data = chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed
//Let’s start our headers
$headers = “From: $Name<” . $_POST[‘Email’] . “>n”;
$headers .= “Reply-To: <” . $_POST[‘Email’] . “>n”;
$headers .= “MIME-Version: 1.0n”;
$headers .= “Content-Type: multipart/related; type=“multipart/alternative”; boundary=”----=MIME_BOUNDRY_main_message"n";
$headers .= “X-Sender: $Name<” . $_POST[‘Email’] . “>n”;
$headers .= “X-Mailer: PHP4n”;
$headers .= “X-Priority: 3n”; //1 = Urgent, 3 = Normal
$headers .= “Return-Path: <” . $_POST[‘Email’] . “>n”;
$headers .= “This is a multi-part message in MIME format.n”;
$headers .= “------=MIME_BOUNDRY_main_message n”;
$headers .= “Content-Type: multipart/alternative; boundary=”----=MIME_BOUNDRY_message_parts"n";
$message = "------=MIME_BOUNDRY_message_partsn";
$message .= "Content-Type: text/plain; charset="iso-8859-1"n"; 
$message .= "Content-Transfer-Encoding: quoted-printablen"; 
$message .= "n"; 
/* Add our message, in this case it's plain text.  You could also add HTML by changing the Content-Type to text/html */
$message .= "$Enquiryn";
$message .= "n"; 
$message .= "------=MIME_BOUNDRY_message_parts--n"; 
$message .= "n"; 
$message .= "------=MIME_BOUNDRY_main_messagen"; 
$message .= "Content-Type: application/octet-stream;ntname="" . $attachment_name . ""n";
$message .= "Content-Transfer-Encoding: base64n";
$message .= "Content-Disposition: attachment;ntfilename="" . $attachment_name . ""nn";
$message .= $data; //The base64 encoded message
$message .= "n"; 
$message .= "------=MIME_BOUNDRY_main_message--n"; 

// send the message
mail("test@test.com.au", $subject, $message, $headers);


print <<< EOT

<?xml version="1.0" encoding="iso-8859-1"?>

Any help would be greatly appreciated