Cześć, mam problem ze swoim formularzem - dochodzi na maila, w informacji maila jest jako by był z załącznikiem ale załącznik nie dochodzi - nie jest nigdzie widoczny. Prosiłbym o pomoc.
[code]<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$model = $_POST["model"];
$rok = $_POST["rok"];
$przebieg = $_POST["przebieg"];
$paliwo = $_POST["paliwo"];
$info = $_POST["info"];
$imie = $_POST["imie"];
$numer = $_POST["numer"];
// File attachment
$file = $_FILES["attachment"];
$file_name = $file["name"];
$file_tmp = $file["tmp_name"];
// Adres e-mail, na który ma zostać wysłana wiadomość
$odbiorca = "sample@sample.pl[php][/php]";
// Temat wiadomości
$temat = "WYCENA ZE STRONY WWW";
// Treść wiadomości
$tresc = "Model: " . $model . "\n";
$tresc .= "Rok: " . $rok . "\n";
$tresc .= "Przebieg: " . $przebieg . "\n";
$tresc .= "Paliwo: " . $paliwo . "\n";
$tresc .= "Info: " . $info . "\n";
$tresc .= "Imie: " . $imie . "\n";
$tresc .= "Numer: " . $numer . "\n";
// Nagłówki wiadomości
$boundary = md5(uniqid(rand(), true));
$naglowki = "From: " . $email . "\r\n";
$naglowki .= "Reply-To: " . $email . "\r\n";
$naglowki .= "Content-Type: multipart/mixed; boundary=\"" . $boundary . "\"\r\n";
// Wiadomość
$message = "--" . $boundary . "\r\n";
$message .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$message .= $tresc . "\r\n";
// Dodawanie załącznika
if (!empty($file_tmp)) {
$file_contents = file_get_contents($file_tmp);
$message .= "--" . $boundary . "\r\n";
$message .= "Content-Type: application/octet-stream\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition: attachment; filename=\"" . $file_name . "\"\r\n\r\n";
$message .= chunk_split(base64_encode($file_contents)) . "\r\n";
}
$message .= "--" . $boundary . "--";
// Wysyłanie wiadomości e-mail
if (mail($odbiorca, $temat, $message, $naglowki)) {
echo "Wiadomość wysłana poprawnie";
} else {
echo "Błąd wysyłania wiadomości";
}
}
?>