Witam,
znalazłem kod w necie:
<form name="form1" method="post" action="sendmail.php" enctype="multipart/form-data"> <table width="300" border="0" cellspacing="0" cellpadding="0"> <tr><td colspan="2"><input type="submit" name="Submit" value="Submit"></td></tr>
<?php
$replyto = $_POST['replyto'];
$subject = $_POST['subject'];
$from = $_POST['from'];
$sendto = $_POST['sendto'];
$message = $_POST['message'];
$filename_name = $_FILES['filename']['name'];
$filename_type = $_FILES['filename']['type'];
$boundary = "-->===_54654747_===<---->>4255==_";
// Zmiennych $subject i $sendto nie musimy w żaden sposób przerabiać.
// Teraz trzeba sformatować nagłówek.
$head = "From: $fromn";
$head = $head . "Reply-To: $replyton";
$head = $head . "X-Mailer: PHPn";
$head = $head . "X-Sender: $fromn";
$head = $head . "MIME-version: 1.0n";
$head = $head . "Content-type: multipart/mixed; ";
$head = $head . "boundary="$boundary"n";
$head = $head . "Content-transfer-encoding: 7BITn";
$head = $head . "X-attachments: $filename_name;nn";
// Jeszcze tylko treść wiadomości i możemy słać pocztę
$mesg = "--" . $boundary . "n"; //pamiętamy dwa minusy na początku
$mesg = $mesg . "Content-Type: text/plain; charset="us-ascii"nn";
$mesg = $mesg . $message . "n";
$mesg = $mesg . "--" . $boundary . "n"; //pamiętamy dwa minusy na początku
$mesg = $mesg . "Content-type: " . $filename_type . "; name="$filename_name";n";
$mesg = $mesg . "Content-Transfer-Encoding: base64n";
$mesg = $mesg . "Content-disposition: attachment; filename= "$filename_name"nn";
$mesg = $mesg . fileopenanddecode($filename_name) . "n"; //czytamy plik i go kodujemy
$mesg = $mesg . "--" . $boundary . "-- n"; //pamiętamy dwa minusy na początku i na końcu
//funkcja odczytująca plik i kodująca go d o formatu base64 zgodnie z RFC 2045
function fileopenanddecode($file) {
}
return $encoded;
}
// i to wszystko teraz tylko
mail($sendto, $subject, $mesg, $head); //i poszło
?>
Załącznik dochodzi ale ma 0 kb. Wie ktoś dlaczego?
Czy plik muszę wrzucić pierwsze na serwer?
Ten post edytował cornholio666 2.04.2007, 20:24:10