Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_FILES['fileFF']['size'] > 0) {
- $output = '<h1>Спасибо! Ваш файл получен.</h1>';
- $to = "хуи@мыло.ру"; // адрес почты получателя
- $anon = htmlspecialchars ($_POST['anon']);
- $from = htmlspecialchars ($_POST['from']);
- $subject = htmlspecialchars ($_POST['subject']);
- $message = htmlspecialchars ($_POST['message']);
- $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF']['tmp_name'])));
- $filename = $_FILES['fileFF']['name'];
- $filetype = $_FILES['fileFF']['type'];
- $boundary = md5(date('r', time())); // рандомное число
- $headers = "From: $anon <" . $from . ">\r\n"; // см. наиболее часто используемые заголовки
- $headers .= "Reply-To: <" . $from . ">\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-Type: multipart/mixed; boundary=\"_1_$boundary\"";
- $message="
- --_1_$boundary
- Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
- --_2_$boundary
- Content-Type: text/plain; charset=\"utf-8\"
- Content-Transfer-Encoding: 7bit
- $message
- --_2_$boundary--
- --_1_$boundary
- Content-Type: \"$filetype\"; name=\"$filename\"
- Content-Transfer-Encoding: base64
- Content-Disposition: attachment // содержимое является вложенным
- $attachment
- --_1_$boundary--";
- mail($to, $subject, $message, $headers);
- }
- ?>
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Свзяь с администрацией</title>
- </head>
- <body>
- <style>
- html, body {
- margin: 0;
- padding: 0;
- font: 14px/1.6 Georgia, Palatino, Palatino Linotype, Times, Times New Roman, serif;
- color: #333;
- background: #eee;
- }
- .form {
- padding: 10px;
- background: #FCFCFC;
- width: 500px;
- margin: 0 auto;
- }
- textarea {
- width: 494px;
- }
- .file {
- width: 100px;
- height: 40px;
- }
- </style>
- <?php echo $output; ?>
- <div class="form">
- <form enctype="multipart/form-data" method="post">
- <input type="text" name="subject" placeholder="Subject Message"><br />
- <input type="text" name="anon" placeholder="Your Name"><br />
- <input type="text" name="from" placeholder="Your E-Mail"><br />
- <textarea name="message" placeholder="Your Text"></textarea><br />
- <input type="file" class="file" name="fileFF"><br />
- <input type="submit" value="Отправить">
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment