Guest User

Untitled

a guest
Dec 11th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.46 KB | None | 0 0
  1. <?php
  2. if($_FILES['fileFF']['size'] > 0) {
  3.  
  4.   $output = '<h1>Спасибо! Ваш файл получен.</h1>';
  5.  
  6.   $to = "хуи@мыло.ру"; // адрес почты получателя
  7.  
  8.   $anon    = htmlspecialchars ($_POST['anon']);
  9.   $from    = htmlspecialchars ($_POST['from']);
  10.   $subject = htmlspecialchars ($_POST['subject']);
  11.   $message = htmlspecialchars ($_POST['message']);
  12.  
  13.   $attachment = chunk_split(base64_encode(file_get_contents($_FILES['fileFF']['tmp_name'])));
  14.   $filename = $_FILES['fileFF']['name'];
  15.   $filetype = $_FILES['fileFF']['type'];
  16.  
  17.   $boundary = md5(date('r', time())); // рандомное число
  18.  
  19.   $headers = "From: $anon <" . $from . ">\r\n"; // см. наиболее часто используемые заголовки
  20.   $headers .= "Reply-To: <" . $from . ">\r\n";
  21.   $headers .= "MIME-Version: 1.0\r\n";
  22.   $headers .= "Content-Type: multipart/mixed; boundary=\"_1_$boundary\"";
  23.  
  24.   $message="
  25. --_1_$boundary
  26. Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
  27.  
  28. --_2_$boundary
  29. Content-Type: text/plain; charset=\"utf-8\"
  30. Content-Transfer-Encoding: 7bit
  31.  
  32. $message
  33.  
  34. --_2_$boundary--
  35. --_1_$boundary
  36. Content-Type: \"$filetype\"; name=\"$filename\"
  37. Content-Transfer-Encoding: base64
  38. Content-Disposition: attachment // содержимое является вложенным
  39.  
  40. $attachment
  41. --_1_$boundary--";
  42.  
  43.   mail($to, $subject, $message, $headers);
  44.  
  45. }
  46. ?>
  47.  
  48. <!DOCTYPE HTML>
  49. <html>
  50.  
  51. <head>
  52.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  53.     <title>Свзяь с администрацией</title>
  54. </head>
  55.  
  56. <body>
  57. <style>
  58. html, body {
  59.     margin: 0;
  60.     padding: 0;
  61.     font: 14px/1.6 Georgia, Palatino, Palatino Linotype, Times, Times New Roman, serif;
  62.     color: #333;
  63.     background: #eee;
  64. }
  65.  
  66. .form {
  67.     padding: 10px;
  68.     background: #FCFCFC;
  69.     width: 500px;
  70.     margin: 0 auto;
  71. }
  72.  
  73. textarea {
  74.     width: 494px;
  75. }
  76.  
  77. .file {
  78.     width: 100px;
  79.     height: 40px;
  80. }
  81. </style>
  82.  
  83. <?php echo $output; ?>
  84.  
  85. <div class="form">
  86.     <form enctype="multipart/form-data" method="post">
  87.         <input type="text" name="subject" placeholder="Subject Message"><br />
  88.         <input type="text" name="anon" placeholder="Your Name"><br />
  89.         <input type="text" name="from" placeholder="Your E-Mail"><br />
  90.         <textarea name="message" placeholder="Your Text"></textarea><br />
  91.         <input type="file" class="file" name="fileFF"><br />
  92.         <input type="submit" value="Отправить">
  93.     </form>
  94. </div>
  95.  
  96. </body>
  97. </html>
Advertisement
Add Comment
Please, Sign In to add comment