php脚本通过电子邮件发送带有附件的联系表单

I have created a form using Dreamweaver/HTML and connected it with a PHP script that emails the form. I know very little of PHP and I'm trying to get the contact form to have an "image upload" that in turn will attach to an email when the form is sent. I tested the form and it works just fine. Only the uploads don't do anything. I was hoping someone could help me with this. Here is my html form.

<form action="quote_form.php" method="post" enctype="multipart/form-data" name="QuoteForm" id="QuoteForm">
  <p>
    <label for="name">Full Name<span style="color: #FF0000">*</span></label>
    <input name="name" type="text" id="name" size="40" maxlength="40" />
  </p>
  <p>
    <label for="phone">Phone #<span style="color: #FF0000">*</span></label>
    <input name="phone" type="text" id="phone" size="30" maxlength="30" />
  </p>
  <p>
    <label for="email">Email<span style="color: #FF0000">*</span></label>
    <input name="email" type="text" id="email" size="30" maxlength="30" />
  </p>
  <span style="font-style: italic">Please check at least one or both boxes<span style="color: #FF0000">*</span></span>
  <p>
    <input type="checkbox" name="servicetype[]" value="pawn" />
    Pawn
    <input type="checkbox" name="servicetype[]" value="buy" />
    Buy<br /><br />
  </p>
  <p><span style="color: #ff9600; font-size: 18px;">Tell Us About Your Item</span><br />
    <span style="font-style: italic">(the more information the better --- description i.e. brand, model and condition of item.)</span></p>
  <p>
    <textarea name="comments" id="comments" cols="50" rows="10"></textarea>
  </p>
  <p>
    <label for="file">Select File To Upload<span style="color: #FF0000">*</span></label>
    <input type="file" name="file" id="file" size="30" maxlength="30" />
  </p>
  <p>
    <input type="submit" name="submit" id="sumbit" value="Submit" />
    <input name="reset" type="reset" id="reset" value="Reset Form" />
  </p>
  <p>
    <input name="recipient" type="hidden" id="recipient" value="isabelpolanco23@gmail.com" />
    <input name="redirect" type="hidden" id="redirect" value="thankyou-pg.html" />
    <br />
  </p>
</form>

And here is my php script to email

<?php
if(isset($_POST['email'])) {
    // FORM DETAILS EMAIL
  $email_to = "myemail@gmail.com";
  $email_subject = "Pawn/Buy Quote Form Results";
    $email_message = "Quote form details below + attachment.

";

  function died($error) {
    // ERROR CODES HERE
    echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
  }

    // VALIDATION EXPECTED DATA EXIST 
  if(!isset($_POST['name']) ||
     !isset($_POST['email']) ||
     !isset($_POST['phone']) ||
     !isset($_POST['comments'])){
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
  }

  // invalid emailaddress
  if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

  }

  //FORM DETAILS     
  $name = $_POST['name']; // required
  $email_from = $_POST['email']; // required
  $phone = $_POST['phone']; // required
  $comments = $_POST['comments']; // required
  $servicetype = array("pawn" => false, "buy" => false);  //checkboxes

  foreach ($_POST["servicetype"] as $value) {
    if ($value=="pawn")
      $servicetype["pawn"] = true;
    else if ($value=="buy")
      $servicetype["buy"] = true;
  }

  //ERROR MESSAGES    
  $error_message = "";
  $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
  $string_exp = "/^[A-Za-z .'-]+$/";
    if(!preg_match($string_exp,$name)) {
    $error_message .= 'The Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
    $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(strlen($error_message) > 0) {
    died($error_message);
  }

  function clean_string($string) {
    $bad = array("content-type","bcc:","to:","cc:","href");
    return str_replace($bad,"",$string);
  }

  //UPLOAD IMAGE
  $allowedExts = array("gif", "jpeg", "jpg", "png");
  $temp = explode(".", $_FILES["file"]["name"]);
  $extension = end($temp);
  if ((($_FILES["file"]["type"] == "image/gif")
       || ($_FILES["file"]["type"] == "image/jpeg")
       || ($_FILES["file"]["type"] == "image/jpg")
       || ($_FILES["file"]["type"] == "image/pjpeg")
       || ($_FILES["file"]["type"] == "image/x-png")
       || ($_FILES["file"]["type"] == "image/png"))
      && ($_FILES["file"]["size"] < 10000)
      && in_array($extension, $allowedExts)) {
    if ($_FILES["file"]["error"] > 0) {
      echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    }
    else {
      echo "Upload: " . $_FILES["file"]["name"] . "<br>";
      echo "Type: " . $_FILES["file"]["type"] . "<br>";
      echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
      echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

      if (file_exists("upload/" . $_FILES["file"]["name"])) {
        echo $_FILES["file"]["name"] . " already exists. ";
      }
      else {
        move_uploaded_file($_FILES["file"]["tmp_name"],
                           "upload/" . $_FILES["file"]["name"]);
        echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      }
    }
  }
  else {
    echo "Invalid file";
  }

  //EMAIL MESSAGE DETAILS     
  $email_message .= "Name: ".clean_string($name)."
";
  $email_message .= "Email: ".clean_string($email_from)."
";
  $email_message .= "Phone: ".clean_string($phone)."
";
  $email_message .= "Pawn: " . clean_string(($servicetype["pawn"]) ? "Yes" : "No") . "
";
  $email_message .= "Buy: " . clean_string(($servicetype["buy"]) ? "Yes" : "No") . "
"; 
  $email_message .= "About My Item: ".clean_string($comments)."
";

  //now Attach all files submitted
  $mail->AddAttachment("uploads"."/".$_FILES["file"]["name"]);

  //EMAIL HEADERS
  $headers = 'From: '.$email_from."
".
    'Reply-To: '.$email_from."
" .
    'X-Mailer: PHP/' . phpversion();
  @mail($email_to, $email_subject, $email_message, $headers);  
?>

<?php
//REDIRECT PAGE
header("Location:thankyou-pg.html");
exit;
?>

<?php
}
?>

You seem to mostly be building up the mail data manually for use with the mail() built-in, but then suddenly you have this line:

$mail->AddAttachment("uploads"."/".$_FILES["image"]["type"]);

Apart from the typo pointed out by Fred in the comments ($_FILES["image"]["type"] should be $_FILES["file"]["name"]), your code doesn't seem to ever define $mail, or use it again.

It looks like you've started looking at a mail library (PHPMailer, SwiftMailer, or similar) but not actually read through the instructions properly. This is probably a good approach - it's much more secure than trying to roll your own string replace routines, and a lot more likely to end up with a valid e-mail once you get into attachments etc - but you need to convert all your code to use the library, not just make one call to it and hope that it will somehow merge in with your existing code.