我的网站上有一个在线资产提交区域,允许用户以带有图片的文字形式发送属性到我的电子邮件地址:
但我没有收到图片。我只收到文字。我试图找出为什么会发生这种情况,但我找不到任何会导致这种情况的事情。有人可以帮我找出问题吗?
代码:
<?php
if (isset($_POST['propertystatus'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "contact@scale-property.com";
$email_subject = "New Property From Customer";
$email_subject_to_user = "Copy of your email";
$propery_Information = 'PROPERTY INFORMATION';
$propery_Location = 'PROPERTY LOCATION';
$contact_Information = 'CONTACT INFORMATION';
function died($error)
{
// your error code can go here
echo "We are very sorry, but there were errors found with the form you submitted.<br>";
echo $error . "<br />";
die();
}
// validation expected data exists
if (!isset($_POST['propertystatus']) || !isset($_POST['currencytype']) || !isset($_POST['currency']) || !isset($_POST['rooms']) || !isset($_POST['bathroom']) || !isset($_POST['kitchen']) || !isset($_POST['yard']) || !isset($_POST['housedesproperty']) || !isset($_POST['drop_1']) || !isset($_POST['drop_2']) || !isset($_POST['drop_3']) || !isset($_POST['region']) || !isset($_POST['street']) || !isset($_POST['name']) || !isset($_POST['emailadd']) || !isset($_POST['conemailadd']) || !isset($_POST['phone1']) || !isset($_POST['phone2']) || !isset($_FILES['uploadimages'])) {
died('You have not properly selected the fields.');
}
// start code of attachement
if (empty($_FILES['uploadimages']['name'])) {
echo 'You have\'nt Entered Value for upload field';
exit();
} else {
$attachment = $_FILES['uploadimages']['tmp_name'];
$attachment_name = $_FILES['uploadimages']['name'];
if (is_uploaded_file($attachment)) {
$fp = fopen($attachment, "rb");
$data = fread($fp, filesize($attachment));
$data = chunk_split(base64_encode($data));
fclose($fp);
}
$headers = "From: $email<$email>\n";
$headers .= "Reply-To: <$email>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: <$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_parts\n";
$message .= "Content-Type: text/html; charset=\"utf-8\"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";
$message .= "------=MIME_BOUNDRY_main_message\n";
$message .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n";
$message .= $data; //The base64 encoded message
$message .= "\n";
$message .= "------=MIME_BOUNDRY_main_message--\n";
mail($email_to, $email_subject, $message, $headers);
}
// end code of attachment
$property_status = $_POST['propertystatus']; // required
$currency_type = $_POST['currencytype']; // required
$currency = $_POST['currency']; // required
$rooms = $_POST['rooms']; // required
$bathroom = $_POST['bathroom']; // required
$kitchen = $_POST['kitchen']; // required
$yard = $_POST['yard']; // required
$housedesproperty = $_POST['housedesproperty']; // required
$drop_1 = $_POST['drop_1']; // required
$drop_2 = $_POST['drop_2']; // required
$drop_3 = $_POST['drop_3']; // required
$region = $_POST['region']; // required
$street = $_POST['street']; // required
$name = $_POST['name']; // required
$emailadd = $_POST['emailadd']; // required
$conemailadd = $_POST['conemailadd']; // required
$phone1 = $_POST['phone1']; // required
$phone2 = $_POST['phone2']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if (!preg_match($email_exp, $emailadd) && !preg_match($email_exp, $conemailadd)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$email_message = "Property details below.\n\n";
function clean_string($string)
{
$bad = array(
"content-type",
"bcc:",
"to:",
"cc:",
"href"
);
return str_replace($bad, "", $string);
}
$email_message .= "" . clean_string($propery_Information) . "\n";
$email_message .= "--------------------------------------------" . "\n";
$email_message .= "Property Status: " . clean_string($property_status) . "\n";
$email_message .= "Total Price: " . clean_string($currency_type) . " " . (number_format($currency, 2, '.', ',')) . "\n";
$email_message .= "Rooms: " . clean_string($rooms) . "\n";
$email_message .= "Bathrooms: " . clean_string($bathroom) . "\n";
$email_message .= "Bathrooms: " . clean_string($kitchen) . "\n";
$email_message .= "Bathrooms: " . clean_string($yard) . "\n";
$email_message .= "Description: " . clean_string($housedesproperty) . "\n\n";
$email_message .= "" . clean_string($propery_Location) . "\n";
$email_message .= "--------------------------------------------" . "\n";
$email_message .= "Province: " . clean_string($drop_1) . "\n";
$email_message .= "District: " . clean_string($drop_2) . "\n";
$email_message .= "PD(Nahya): " . clean_string($drop_3) . "\n";
$email_message .= "Bathrooms: " . clean_string($region) . "\n";
$email_message .= "Street: " . clean_string($street) . "\n\n";
$email_message .= "" . clean_string($contact_Information) . "\n";
$email_message .= "--------------------------------------------" . "\n";
$email_message .= "Name: " . clean_string($name) . "\n";
$email_message .= "Email ID: " . clean_string($emailadd) . "\n";
$email_message .= "Con-Email ID: " . clean_string($conemailadd) . "\n";
$email_message .= "Phone(1): " . clean_string($phone1) . "\n";
$email_message .= "Phone(2): " . clean_string($phone2) . "\n";
// create email headers
$headers = 'From: ' . $emailadd . "\r\n" . 'Reply-To: ' . $emailadd . "\r\n" . 'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
@mail($emailadd, $email_subject_to_user, $email_message, "From: $email_to");
?>
<!-- include your own success html here -->
Your Property has been Posted please check your email address.
<?php
}
?>
答案 0 :(得分:0)