Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php + ajax] formularz z załącznikiem
piotrd
post 17.08.2007, 21:12:49
Post #1





Grupa: Zarejestrowani
Postów: 174
Pomógł: 0
Dołączył: 16.05.2006
Skąd: Łódź

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


witam, mam skrypt:
  1. <html>
  2.  
  3. <head>
  4. <script>
  5. function MultiSelector( list_target, max ){this.list_target = list_target;this.count = 0;this.id = 0;if( max ){this.max = max;} else {this.max = -1;};this.addElement = function( element ){if( element.tagName == 'INPUT' && element.type == 'file' ){element.name = 'file_' + this.id++;element.multi_selector = this;element.onchange = function(){var new_element = document.createElement( 'input' );new_element.type = 'file';this.parentNode.insertBefore( new_element, this );this.multi_selector.addElement( new_element );this.multi_selector.addListRow( this );this.style.position = 'absolute';this.style.left = '-1000px';};if( this.max != -1 && this.count >= this.max ){element.disabled = true;};this.count++;this.current_element = element;} el
    se {alert( 'Error: brak pliku' );};};this.addListRow = function( element ){var new_row = document.createElement( 'div' );var new_row_button = document.createElement( 'input' );new_row_button.type = 'button';new_row_button.value = 'usun';new_row.element = element;new_row_button.onclick= function(){this.parentNode.element.parentNode.removeChild( this.parentNode.element );this.parentNode.parentNode.removeChild( this.parentNode );this.parentNode.element.multi_selector.count--;this.parentNode.element.multi_selector.current_element.disabled = false;return 
    false;};new_row.innerHTML = element.value;new_row.appendChild( new_row_button );this.list_target.appendChild( new_row );};};
  6. </script>
  7. </head>
  8.  
  9. <body>
  10. <?
  11. $adres = "mail@gmail.com";
  12.  
  13. $topic = "=?iso-8859-2?B?".base64_encode("WSRM Łódź: e-mail z załącznikiem")."?=";
  14.  
  15. $headers = "MIME-Version: 1.0r\n";
  16. $headers .= "Content-Transfer-Encoding: 8bitr\n";
  17. $headers .= "Content-Type: text/html; charset=iso-8859-2r\n";
  18. $headers .= "From: mail@gmail.comr\n";
  19.  
  20. $tresc_plus = "Treść maila:<br /><strong>".$imie."<br />".$mail."<br />".$numer."<br />".$temat."</strong><br /><pre>".$wiadomosc."</pre>";
  21.  
  22. mail ($adres, $topic, $tresc_plus, $headers);
  23. ?>
  24. <form name="formularz" enctype="multipart/form-data" action="" method = "post" />
  25. Imię i nazwisko:<br />
  26. <INPUT NAME="imie" TYPE="text" SIZE="25" value="" />
  27. <br />
  28. Kontakt (e-mail):<br />
  29. <input name="mail" type="text" SIZE="25" value="" />
  30. <br />
  31. Kontakt (telefon):<br />
  32. <INPUT NAME="numer" TYPE="text" MAXLENGTH="9" value="" />
  33. <br />
  34. Temat:<br />
  35. <select name="temat">
  36. <option>temat 1</option>
  37. <option>temat 2</option>
  38. </select>
  39. <br />
  40. Treść:<br />
  41. <TEXTAREA NAME="wiadomosc" COLS="50" ROWS="9"></textarea>
  42. <br />
  43. <input id="my_file_element" type="file" name="file_1" />
  44. <br />
  45. <INPUT NAME="submit" TYPE="submit" VALUE="wyślij" />
  46. </form>
  47. <br />
  48. Pliki:
  49. <div id="files_list"></div>
  50. <script>
  51. var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 3 );
  52. multi_selector.addElement( document.getElementById( 'my_file_element' ) );
  53. </script>
  54.  
  55. </body>
  56. </html>

proszę Was o podpowiedź dlaczego załączniki są pomijane?


--------------------
piotrd
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
gebp
post 18.08.2007, 09:02:38
Post #2





Grupa: Zarejestrowani
Postów: 180
Pomógł: 6
Dołączył: 10.04.2006

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


AJAX'em nie można pobierać plików.
Go to the top of the page
+Quote Post
piotrd
post 18.08.2007, 09:31:02
Post #3





Grupa: Zarejestrowani
Postów: 174
Pomógł: 0
Dołączył: 16.05.2006
Skąd: Łódź

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


ale a ajaxie wyświetlam tylko pliki załączone w <input id="my_file_element" type="file" name="file_1" /> itd wiec nie powinno być problemu


--------------------
piotrd
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 Wersja Lo-Fi Aktualny czas: 24.07.2025 - 22:53