Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][PHP]Formularz nie wysyla pliku na e-mail, cos trzeba zmienic
dufia
post 24.03.2010, 22:21:28
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 27.02.2010

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


Zaznaczam, ze mam tylko podstawowa wiedze z PHP, kod jest skopiowany i zmodyfikowany tylko troszeczke.


  1. <div id="enquiryForm2">
  2.  
  3. <?php
  4. if (count($_POST))
  5. {
  6. ////////// USTAWIENIA //////////
  7. $email = 'email'; // Adres e-mail adresata
  8. $subject = 'ENQUIRY FORM FROM WEBSITE'; // Temat listu
  9. $message = 'Thank you! Yours form have been sended. If you have done it properly, we answer you very soon!'; // Komunikat
  10. $error = 'Sorry, an error occurred, please try again. '; // Komunikat błędu
  11. $charset = 'utf-8'; // Strona kodowa
  12.  
  13. //////////////////////////////
  14.  
  15. $head =
  16. "MIME-Version: 1.0\r\n" .
  17. "Content-Type: text/plain; charset=$charset\r\n" .
  18. "Content-Transfer-Encoding: 8bit";
  19. $body = '';
  20. foreach ($_POST as $name => $value)
  21. {
  22. if (is_array($value))
  23. {
  24. for ($i = 0; $i < count($value); $i++)
  25. {
  26. $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value[$i]) : $value[$i]) . "\r\n";
  27. }
  28. }
  29. else $body .= "$name=" . (get_magic_quotes_gpc() ? stripslashes($value) : $value) . "\r\n";
  30. }
  31. echo mail($email, "=?$charset?B?" . base64_encode($subject) . "?=", $body, $head) ? $message : $error;
  32. }
  33.  
  34. else
  35. {
  36. ?>
  37.  
  38. <form action="?" method="post" enctype="multipart/form-data">
  39. <div id="enquiryFormInput1">
  40. <input type="text" name="firstname" size="30" maxlength="30" />
  41. </div>
  42. <div id="enquiryFormInput2">
  43. <input type="text" name="surname" size="30" maxlength="30" />
  44. </div>
  45. <div id="enquiryFormInput3">
  46. <input type="text" name="home address" size="30" maxlength="60" />
  47. </div>
  48. <div id="enquiryFormInput4">
  49. <input type="text" name="email address" size="30" maxlength="30" />
  50. </div>
  51. <div id="enquiryFormInput5">
  52. <input type="text" name="prefered work" size="30" maxlength="30" />
  53. </div>
  54. <div id="enquiryFormInput6">
  55. <input type="file" name="cv" size="19" accept="application/msword,text/plain" />
  56. </div>
  57. <div id="enquiryFormInput7">
  58. <input type="image" src="images/form_40.jpg " alt="SEND" />
  59. </div>
  60.  
  61. </form>
  62. <?php
  63. }
  64. ?>
  65. </div>


problem:

samo w sobie dziala, wysyla dane z formularza na podany adres email

Problem jest taki, ze nie dodaje zalacznika. Oryginalny skrypt wysylal tylko sam text, wiec trzeba to jakos przysyosowac, ale nie ogarniam niestety.

Zamiast dodawac plik, pobiera tylko jego nazwe i wysyla na mail sad.gif

Nie wiem za co sie zabrac, da sie wyslac ten plik bez upladowania go na serwer? czy pierwsza czynnosc jaka musze zrobic to uploadowac plik na serwer? Jak to zrobic? wstydnis.gif


Z gory dziekuje za kazda pomoc,
Pozdrawiam
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 17:14