Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Formularz z załącznikami, Lak dodać dodatkowy załącznik do formularza
Arteline
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 11.03.2008

Ostrzeżenie: (0%)
-----


Witam.
Byłabym BARDZO wdzięczna jeśli ktoś mógłby mi podpowiedzieć jak dodać dodatkowe pole załącznika w skrypcie który podpinam poniżej.
Formularz
  1. <?php
  2. <form enctype="multipart/form-data" name=doit action="sendmail.php3" method=POST>
  3. <table cellpadding=0 cellspacing=0>
  4. <tr><td><b>Tob></td><td><input type="text" name="to" size=40></td></tr>
  5. <tr><td><b>Ccb></td><td><input type="text" name="cc" size=40></td></tr>
  6. <tr><td><b>Bccb></td><td><input type="text" name="bcc" size=40></td></tr>
  7. <tr><td><b>Fileb></td><td><input type=file name="attach" size=40></td></tr>
  8. <tr><td><b>Subjectb></td><td><input type="text" name="subject" size=40>
  9. </td></tr></table>
  10. <textarea name="body" rows=15 cols=50 wrap="message">
  11. </textarea>
  12. <input type="submit" name="sendmail" value="Send">
  13. ?>

sendmail
  1. <?
  2.  
  3. $mailheaders  = "Fro: $from\n";
  4. $mailheaders .= "Reply-To: $from\n";
  5. $mailheaders .= "Cc: $cc\n";
  6. $mailheaders .= "X-Mailer: PHP by www.mjs27.prv.pl\n";
  7.  
  8. $msg_body = stripslashes($body);
  9.  
  10. if ($attach != "none")
  11. {
  12.    $file = fopen($attach, "r");
  13.    $contents = fread($file, $attach_size);
  14.    $encoded_attach = chunk_split(base64_encode($contents));
  15.    fclose($file);
  16.        
  17.    $mailheaders .= "MIME-versio: 1.0\n";
  18.    $mailheaders .= "Content-typ: multipart/mixed; ";
  19.    $mailheaders .= "boundary=\"Message-Boundary\"\n";
  20.    $mailheaders .= "Content-transfer-encodin: 7BIT\n";
  21.    $mailheaders .= "X-attachment: $attach_name";
  22.  
  23.    $body_top = "--Message-Boundary\n";
  24.    $body_top .= "Content-typ: text/plain; charset=US-ASCII\n";
  25.    $body_top .= "Content-transfer-encodin: 7BIT\n";
  26.    $body_top .= "Content-descriptio: Mail message body\n\n";
  27.  
  28.    $msg_body = $body_top . $msg_body;
  29.  
  30.    $msg_body .= "\n\n--Message-Boundary\n";
  31.    $msg_body .= "Content-typ: $attach_type; name=\"$attach_name\"\n";        
  32.    $msg_body .= "Content-Transfer-Encodin: BASE64\n";
  33.    $msg_body .= "Content-dispositio: attachment; filename=\"$attach_name\"\n\n";
  34.    $msg_body .= "$encoded_attach\n";
  35.    $msg_body .= "--Message-Boundary--\n";
  36. }
  37.  
  38. mail($to, stripslashes($subject), $msg_body, $mailheaders);
  39. ?>


Marzeniem byłaby jeszcze informacja jak zablokować opcje wysyłania bez dodania choćby jednego załącznika.

Ten post edytował Arteline 16.09.2008, 12:44:38
Go to the top of the page
+Quote Post

Posty w temacie


Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 22:23