Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][PHP]Formularz nie wysyla pliku na e-mail, cos trzeba zmienic
dufia
post
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
 
Start new topic
Odpowiedzi (1 - 2)
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Doczytaj jak się odbiera pliki z formularza, bo brak ci elementarnej wiedzy na ten temat
http://www.php.net/manual/pl/features.file...post-method.php

A następnie doczytaj jak się wysyła mailem pliki, bo i tu z wiedzą nie za dobrze
http://pl.php.net/manual/pl/function.mail.php
Przejrzyj komentarze


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
dufia
post
Post #3





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

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


czytam i kumam powoli, musze plik uploadowac, potem przeczytac uzywajac fopen i dodac do wiadomosci

  1. <form action="upload.php" method="post" enctype="multipart/form-data">
  2. <div id="enquiryFormInput1">
  3. <input type="text" name="firstname" size="30" maxlength="30" />
  4. </div>
  5. <div id="enquiryFormInput2">
  6. <input type="text" name="surname" size="30" maxlength="30" />
  7. </div>
  8. <div id="enquiryFormInput3">
  9. <input type="text" name="home address" size="30" maxlength="60" />
  10. </div>
  11. <div id="enquiryFormInput4">
  12. <input type="text" name="email address" size="30" maxlength="30" />
  13. </div>
  14. <div id="enquiryFormInput5">
  15. <input type="text" name="prefered work" size="30" maxlength="30" />
  16. </div>
  17. <div id="enquiryFormInput6">
  18. <input type="hidden" name="MAX_FILE_SIZE" value="10000" />
  19. <input type="file" name="userfile" size="19" accept="application/msword,text/plain" />
  20. </div>
  21. <div id="enquiryFormInput7">
  22. <input type="image" src="images/form_40.jpg " alt="SEND" />
  23. </div>


formularz, idze do upload.php gdzie jest to

  1. <?php
  2. // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
  3. // of $_FILES.
  4.  
  5. $uploaddir = '/var/www/uploads/';
  6. $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
  7.  
  8. echo '<pre>';
  9. if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
  10. echo "File is valid, and was successfully uploaded.\n";
  11. } else {
  12. echo "Possible file upload attack!\n";
  13. }
  14.  
  15. echo 'Here is some more debugging info:';
  16. print_r($_FILES);
  17.  
  18. print "</pre>";
  19.  
  20. ?>




i dostaje niestety possible file upload attack sad.gif


musze zmienic $uploaddir? nie mam folderu tmp na serwerze, w tym problem?

link do formularza http://www.dufia.ayz.pl/root/lookfw_cate.php
Go to the top of the page
+Quote Post

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 Aktualny czas: 21.08.2025 - 12:33